[swift-evolution] For... else

Howard Lovatt howard.lovatt at gmail.com
Mon Jan 25 03:41:17 CST 2016


It would be easy enough to add:

func forEach(
    @noescape elements body: (Element) throws -> Void,
    @noescape otherwise otherwise: () throws -> Void
) rethrows

to the standard library or write it yourself.

> On 23 Jan 2016, at 12:59 PM, Félix Cloutier via swift-evolution <swift-evolution at swift.org> wrote:
> 
> I frequently need something like that and I'd like to have it in Swift too.
> 
> Félix
> 
>> Le 22 janv. 2016 à 13:22:45, Ben Langmuir via swift-evolution <swift-evolution at swift.org> a écrit :
>> 
>> Previous discussion here:
>> https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001110.html
>> 
>> 
>>> On Jan 22, 2016, at 8:22 AM, Lee M via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> This has likely been discussed already, but I haven't been able to find it anywhere.
>>> Example:
>>> 
>>>    let items: Int = []
>>> 
>>>    for item in items {
>>>        print(item)
>>>    }
>>>    else {
>>>        print("No items")
>>>    }
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160125/5a36c367/attachment.html>


More information about the swift-evolution mailing list