> I don't think this use case warrants a syntax change since it can already be
> expressed quite elegantly with
>
> let test: [Int]? = nil
>
> test?.forEach { i in
> print(i)
> }
> What about just use
>
> test?.forEach { print($0) }
This works for the simple example, but it isn't as powerful:
if let test = test {
for i in test {
if i == 42 {
break
}
}
}
You could add
func forEach(_ body: (Element) throws -> Bool) rethrows
but even this would be less powerful as a loop, which allows you to break,
continue or return as you like._______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution