[swift-evolution] Please remove obscure "!" requirements for implicitly unwrapped optionals
Per Melin
p at greendale.se
Fri Dec 4 15:18:48 CST 2015
On Fri, Dec 4, 2015 at 1:03 AM, Amir Michail <a.michail at me.com> wrote:
>
> I really don’t like having to put the ! suffix in boolean contexts:
>
To be explicit:
let a: Bool! = false
if a == false { } // Works as expected
if !a { } // Works as expected
if a { } // "error: optional type 'Bool!' cannot be used as a
boolean; test for '!= nil' instead"
Xcode "fixes" the last line like this:
if (a != nil) { }
> "if displayFlag! { ... }" instead of "if displayFlag { … }" etc.
>
> If you also want a way to compare with nil, then maybe have this for
> implicitly unwrapped optionals:
>
> if displayFlag? == nil { … }
> _______________________________________________
> 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/20151204/863392a7/attachment.html>
More information about the swift-evolution
mailing list