[swift-users] for with optional collection?

Marco S Hyman marc at snafu.org
Thu Feb 9 15:48:40 CST 2017


> On Feb 9, 2017, at 1:26 PM, Rick Mann via swift-users <swift-users at swift.org> wrote:
> 
> Is there any concise way to write the following?
> 
> if let collection = someOptionalCollection
> {
>    for item in collection
>    {
>    }
> }

someOptionalCollection?.map {
    /* do something with $0 /*
}




More information about the swift-users mailing list