Skip to content

Instantly share code, notes, and snippets.

@AppleCEO
Created May 27, 2019 09:20
Show Gist options
  • Select an option

  • Save AppleCEO/796f5bf9df00c6abe1fe15ec519579ca to your computer and use it in GitHub Desktop.

Select an option

Save AppleCEO/796f5bf9df00c6abe1fe15ec519579ca to your computer and use it in GitHub Desktop.
부모 클래스가 있을 때 이니셜라이저 위임
class Shape {
var numberOfSides: Int = 0
var name: String
init(name: String) {
self.name = name
}
}
class Square: Shape {
var sideLength: Double
init(sideLength: Double, name: String) {
self.sideLength = sideLength
super.init(name: name)
}
}
let square = Square(sideLength: 33.3, name: "운동장")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment