Classes and Inheritance
KOTLIN 공식 레퍼런스 Classes and Inheritance 챕터를 번역한 내용입니다.
Constructors
class Person constructor(firstName: String) { /*...*/ }
class Person(firstName: String) { /*...*/ } // constructor는 생략 가능하다class InitOrderDemo(name: String) {
val firstProperty = "First property: $name".also(::println)
init {
println("First initializer block that prints ${name}")
}
val secondProperty = "Second property: ${name.length}".also(::println)
init {
println("Second initializer block that prints ${name.length}")
}
}
// result
First property: hello
First initializer block that prints hello
Second property: 5
Second initializer block that prints 5Secondary constructors
Class members
Inheritance
Overriding methods
Overriding properties
파생 클래스 초기화 우선 순위
부모 클래스 구현 호출하기
재정의 규칙
추상 클래스
상수형 오브젝트
Last updated