262f57d938
1) dataClass.kt - test with data class 2) receiver.kt - test with Int extension receiver 3) delegation.kt - test with implementation by delegation
19 lines
397 B
Kotlin
Vendored
19 lines
397 B
Kotlin
Vendored
interface Base {
|
|
fun printMessage()
|
|
fun printMessageLine()
|
|
}
|
|
|
|
class BaseImpl(val x: Int) : Base {
|
|
override fun printMessage() { print(x) }
|
|
override fun printMessageLine() { println(x) }
|
|
}
|
|
|
|
class Derived(b: Base) : Base by b {
|
|
override fun printMessage() { print("abc") }
|
|
}
|
|
|
|
fun main() {
|
|
val b = BaseImpl(10)
|
|
Derived(b).printMessage()
|
|
Derived(b).printMessageLine()
|
|
} |