svenjacobs
04/21/2016, 9:37 AMinit block?
abstract class Test() {
abstract val test: String
init {
println(test)
}
fun print() = println(test)
}
class Test2() : Test() {
override val test = "Hello world"
}
val test = Test2() // Output: "null"
test.print() // Output: "Hello world”
In Java the same code would work when accessing an abstract method within the constructor. What is the same pattern in Kotlin?