[swift-evolution] [Pitch] Nil struct

John McCall rjmccall at apple.com
Tue Nov 8 15:52:49 CST 2016


> On Nov 8, 2016, at 1:07 PM, Anton Zhilin via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 2016-11-08 23:53 GMT+03:00 Pyry Jahkola <pyry.jahkola at iki.fi <mailto:pyry.jahkola at iki.fi>>:
> 
> 
> 
> Then why not just:
> 
>     public protocol ExpressibleByIntLiteral {
>       static var `nil`: Self
>     }
> 
> …such that Foo.nil creates your nil value of type Foo?
> 
> 
> This proposal is not about creating an alternate syntax for nil as Optional<Foo>. It’s about granting nil literal its own type:
> 
> let a = nil
> print(type(of: a))  //=> Nil

Is this desirable?

John.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161108/41ef1d34/attachment.html>


More information about the swift-evolution mailing list