【发布时间】:2016-03-29 19:26:27
【问题描述】:
我正在将地图应用于其中包含 try 的字典。如果映射项无效,我想跳过迭代。
例如:
func doSomething<T: MyType>() -> [T]
dictionaries.map({
try? anotherFunc($0) // Want to keep non-optionals in array, how to skip?
})
}
在上面的示例中,如果anotherFunc 返回nil,如何退出当前迭代并继续下一个迭代?这样,它就不会包含nil 的项目。这可能吗?
【问题讨论】:
标签: swift generics swift2 try-catch swift2.2