[swift-evolution] Initializers

Joe Groff jgroff at apple.com
Mon Jan 30 16:08:16 CST 2017

> On Jan 30, 2017, at 12:36 PM, Robert Widmann via swift-evolution <swift-evolution at swift.org> wrote:
> This seems to contradict Swift’s goal of being safe by default, no?  It would make me incredibly uncomfortable if there were a backdoor in DI, even if that backdoor emitted traps when it fails.

There already is a backdoor of sorts. This is one of the intended use cases for implicitly-unwrapped optionals. If you don't want to be hassled by DI, declare a property as T! type, and it will be implicitly initialized to nil, and trap if you try to use it as an unwrapped T without initializing it first.


More information about the swift-evolution mailing list