[swift-evolution] [Pitch] Nil struct

Adrian Zubarev adrian.zubarev at devandartist.com
Tue Nov 8 15:01:07 CST 2016

This is a clean approach but that would not solve the example I mentioned.

let document: Document = [
    "key" = nil // won't work for the second version of the implementation I mentioned
Do solve this problem here, I’d need a real Nil type I could extend.

extension Nil : MyProtocol { … }
Than the above example will work correctly.

Adrian Zubarev
Sent with Airmail

Am 8. November 2016 um 21:53:44, Pyry Jahkola (pyry.jahkola at iki.fi) schrieb:

If we start from this thought…

Adrian Zubarev wrote:
Shouldn’t it be just like this:
public protocol ExpressibleByNilLiteral {

  init(nilLiteral: Nil)

Then why not just:

    public protocol ExpressibleByIntLiteral {
      static var `nil`: Self

…such that Foo.nil creates your nil value of type Foo?

— Pyry

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

More information about the swift-evolution mailing list