[swift-evolution] Conditional casting and conditional binding: Wierd edge case or flawed design

Anton Zhilin antonyzhilin at gmail.com
Sun Oct 9 19:59:21 CDT 2016


A quick fix:

guard let value = dict["Key"].map({ $0 as NSString }) {
    use(value)
}

Current behavior is quite logical: main purpose of as? is to perform casts,
which are not guaranteed to succeed. But I’d say that as? should also
support what you want.
​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161010/2d2f37a2/attachment.html>


More information about the swift-evolution mailing list