[swift-users] for with optional collection?

David Hart david at hartbit.com
Fri Feb 10 00:43:40 CST 2017


someOptionalCollection?.forEach { item in
}

> On 9 Feb 2017, at 22:48, Marco S Hyman via swift-users <swift-users at swift.org> wrote:
> 
> 
>> 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 /*
> }
> 
> 
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users



More information about the swift-users mailing list