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

tuuranton at tutanota.de tuuranton at tutanota.de
Mon May 16 09:09:35 CDT 2016


Why does the following code compile?Why does Bar's init(x: Int) automatically 
call Foo's init()?Why don't I have to manually call super.init() myself?
What passage 
ofhttps://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Initialization.html#//apple_ref/doc/uid/TP40014097-CH18-ID203tells 
me that this should be the case?
--------------------class Foo {    init() {        print("foo init")    
}}class Bar: Foo {    init(x: Int) {        print("bar init")    }}let b = 
Bar(x: 0)//prints://    bar init//    foo init
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160516/31b830a3/attachment.html>


More information about the swift-users mailing list