5
Yapmaya çalıştığım şey, bir sınıf yöntemini süslemek.
Kotlin, neden Derived
'u nihai olarak tanımladı? Derived
'un final olmaması için bir yolu var mı?
Java:
new Derived(new BaseImpl(10)) { // Getting the error on this line: `Cannot inherit from final 'Derived'`
};
Kotlin: Buradan
interface Base {
fun print()
}
class BaseImpl(val x: Int) : Base {
override fun print() { print(x) }
}
class Derived(b: Base) : Base by b
* Örnek: https://kotlinlang.org/docs/reference/delegation.html