Created
May 11, 2020 21:56
-
-
Save hossamghareeb/eac26ddb17e369e0dd8b635638cceee1 to your computer and use it in GitHub Desktop.
memberwise init with custom init
This file contains 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
// No memberwise initializer | |
struct Player { | |
let name: String | |
var score: Int = 0 | |
init(json: [String: AnyObject]) { | |
} | |
} | |
// you have the both initializers: | |
struct Player { | |
let name: String | |
var score: Int = 0 | |
} | |
extension Player { | |
init(json: [String: AnyObject]) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment