[swift-evolution] for in? optionalCollection {

Derrick Ho wh1pch81n at gmail.com
Sat Feb 11 08:40:32 CST 2017


let test: [Int]? = nil
for b in test ?? [] where b != 42 {
   Print(b)

}

I don't think you need new syntax since what you want can be accomplished
quite succinctly already


On Sat, Feb 11, 2017 at 8:18 AM Anton Zhilin via swift-evolution <
swift-evolution at swift.org> wrote:

for i in test ?? [] {
    print(i)
}

For a more general solution, we could add Optional.flatten() to support
optional sequences:

for i in test.flatten() {
    print(i)
}

​
_______________________________________________
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/20170211/0abca6bd/attachment.html>


More information about the swift-evolution mailing list