Skip to content

Instantly share code, notes, and snippets.

@ezura
Created February 22, 2016 12:55
Show Gist options
  • Save ezura/f247eb40bde145e5fbcd to your computer and use it in GitHub Desktop.
Save ezura/f247eb40bde145e5fbcd to your computer and use it in GitHub Desktop.
required 不要になるパターンめも #CodePiece
protocol HogeProtocol {
init(name: String)
}
class HogeClass : HogeProtocol {
required init(name: String) { // HogeProtocol の init(name: String) 必須
}
}
class Hige : HogeClass {
required init(name: String) { // HogeProtocol の init(name: String) 必須
super.init(name: name)
}
}
final class FinalClass : HogeProtocol {
init(name: String) { // final あるから継承できない -> required 不要
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment