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

Erica Sadun erica at ericasadun.com
Sun Oct 9 20:02:01 CDT 2016


If you'd like more context to the conversation:
How do I: Cast an optional string to NSString <http://ericasadun.com/2016/10/08/how-do-i-cast-an-optional-string-to-nsstring/>

-- E


> On Oct 9, 2016, at 6:59 PM, Anton Zhilin <antonyzhilin at gmail.com> wrote:
> 
> 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/20161009/e83baec3/attachment.html>


More information about the swift-evolution mailing list