Intermédiaire
open class Base(val name: String) {
init { println("Initializing Base") }
open val size: Int =
name.length.also { println("Initializing size in Base: $it") }
}
class Derived(
name: String,
val lastName: String
) : Base(name.capitalize().also { println("Argument for Base: $it") }) {
init { println("Initializing Derived") }
override val size: Int =
(super.size + lastName.length).also { println("Initializing size in Derived: $it") }
}
L'éxecution de val derived = Derived("jean", "Dupont")
, affiche :
Modifier
0
Évaluations de la communautéPersonne n'a encore évalué cette question, soyez le premier !
Questions similairesPlus de questions sur Kotlin