Last active
August 29, 2015 14:06
-
-
Save ashfurrow/88cbd0b6de626706f853 to your computer and use it in GitHub Desktop.
Swift initializer problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
let i: Int | |
let j: Int | |
init (i: Int, j: Int) { | |
self.i = i | |
self.j = j | |
} | |
convenience init(i: Int) { | |
self.init(i: i, j: 0) | |
} | |
} | |
class B: A { | |
override init(i: Int, j: Int) { | |
super.init(i: i, j: j) | |
} | |
convenience init(i: Int) { | |
self.init(i: i, j: 0) | |
} | |
convenience init(ix: Int) { | |
self.init(i: ix, j: 0) | |
} | |
} | |
let b = B(i: 1) // "Missing argument for parameter 'j' in call" | |
let b = B(ix: 1) // Works fine |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment