Kotlin에서는 companion object 사용
class Person private constructor(
val name: String,
val age: Int
) {
companion object {
private const val MIN_AGE = 1
fun newBaby(name: String) : Person {
return Person(name, MIN_AGE)
}
}
}
object singleton
moveSomething(object : Movable {
override fun move() {
~~~
}
override fun fly() {
~~~
}
})