Hullaballoonatic
06/19/2019, 5:53 PMBar1 was also added to foos, but I imagine in other cases, that would be horrendousHullaballoonatic
06/19/2019, 5:57 PMHullaballoonatic
06/19/2019, 6:02 PMstreetsofboston
06/19/2019, 6:05 PMfoos is not null. You can have forward declarations. Circular declarations may have some weird behavior, though.Hullaballoonatic
06/19/2019, 6:05 PMHullaballoonatic
06/19/2019, 6:05 PMstreetsofboston
06/19/2019, 6:06 PMstreetsofboston
06/19/2019, 6:09 PMabstract class Base(val base: Base?, val id: Int) {
init {
println("Initing $base with id $id")
}
}
object A: Base(B, 1)
object B: Base(A, 2)
fun main() {
println("{$A.base} and ${B.base}")
}
Cyclical ; not sure if behavior is defined or undefined, but I guess you shouldn’t count on it 🙂Hullaballoonatic
06/19/2019, 6:10 PMlouis993546
06/19/2019, 6:12 PMBar1
https://pl.kotl.in/z0dp394Jkstreetsofboston
06/19/2019, 6:12 PMabstract class Base(val base: Base?, val id: Int) {
init {
println("Initing $base with id $id")
}
}
object A: Base(B, 1)
object B: Base(A, 2)
fun main() {
println("Main")
println("{$A.base} and ${B.base}")
}
You’ll see that Main is printed before the Initing .. ones
Main
Initing null with id 2
Initing cycle.B@2c7b84de with id 1
{cycle.A@3fee733d.base} and nullHullaballoonatic
06/19/2019, 6:16 PMprintln(A.b) it instantiates A, which then calls B to set A.b, so now B is being instantiated, which then calls A to set B.a, which is already instantiatedstreetsofboston
06/19/2019, 6:18 PMobject initialization is a bit lazy.Hullaballoonatic
06/19/2019, 6:18 PMfun Any.ping() = this