[swift-users] super.init() called automatically?

Chris Lattner clattner at apple.com
Tue May 17 23:28:53 CDT 2016


On May 17, 2016, at 2:48 AM, tuuranton at tutanota.de wrote:
> Why is this the intentional behavior? Seems a bit strange that init() is a special exception to the rule.

Two reasons:

1) No one wants to call super.init() when deriving from NSObject.
2) More generally, if there is exactly one DI in your superclass, and if it takes zero arguments, it is usually not interesting to have to call it, it is just boilerplate.

If you think that this is the wrong policy, please bring it up on swift-evolution.  Note that this has been the behavior since Swift 1, and I haven’t heard any other serious complaints about it.

-Chris


More information about the swift-users mailing list