<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div>Why does the following code compile?</div><div>Why does Bar's init(x: Int) automatically call Foo's init()?</div><div>Why don't I have to manually call super.init() myself?</div><div><br /></div><div>What passage of</div><div><a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Initialization.html#//apple_ref/doc/uid/TP40014097-CH18-ID203" target="_blank">https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Initialization.html#//apple_ref/doc/uid/TP40014097-CH18-ID203</a></div><div>tells me that this should be the case?</div><div><br /></div><div>--------------------</div><div>class Foo {</div><div> init() {</div><div> print("foo init")</div><div> }</div><div>}</div><div>class Bar: Foo {</div><div> init(x: Int) {</div><div> print("bar init")</div><div> }</div><div>}</div><div>let b = Bar(x: 0)</div><div>//prints:</div><div>// bar init</div><div>// foo init</div> </body>
</html>