[swift-evolution] Pitch: Remove default initialization of optional bindings

Adrian Zubarev adrian.zubarev at devandartist.com
Mon Nov 6 16:40:56 CST 2017


Just a quick question for clarification. What will happen to these? Do we have to provide the default value ourselves?

class ViewController : UIViewController {

    @IBOutlet weak var view1: UIView?

    @IBOutlet weak var view2: UIView!
}


Am 6. November 2017 um 23:33:51, Slava Pestov via swift-evolution (swift-evolution at swift.org) schrieb:

Hi all,

Right now, the following two declarations are equivalent:

struct S {
var x: Int?
}

struct S {
var x: Int? = nil
}

That is, mutable bindings of sugared optional type (but not Optional<T>!) always have a default value of ‘nil’. This feature increases the surface area of the language for no good reason, and I would like to deprecate it in -swift-version 5 with a short proposal. Does anyone feel strongly about giving it up? I suspect most Swift users don’t even know it exists.

Slava
_______________________________________________
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/20171106/3a288fc3/attachment.html>


More information about the swift-evolution mailing list