Files
kotlin-examples/Writerside/topics/Delegation.md
2024-06-21 15:01:25 +09:00

18 lines
234 B
Markdown

# 위임
```kotlin
interface Base {
fun print()
}
class BaseImpl(val x: Int) : Base {
override fun print() { print(x) }
}
class Derived(b: Base) : Base by b
fun main(){
val b = BaseImpl(10)
Derived(b).print()
}
```