123
03/07/2021, 12:16 PM.toString()
except overriding it? I have a LAZY collection in a data class, so it throws an exception on .toString()
Adam Powell
03/07/2021, 2:23 PMnkiesel
03/10/2021, 3:24 AMfun foo() = (1..10).random()
data class D(val a: Int) {
val b: Int by lazy { foo() }
}
val d1 = D(33)
println("d1 is $d1 and d1.b is ${d1.b}")
val d2 = D(33)
println("d2.b is ${d2.b} and d1 and d2 are equal: ${d1 == d2}")
which printed for me:
d1 is D(a=33) and d1.b is 9
d2.b is 6 and d1 and d2 are equal: true