07/13/2022, 2:31 PM
Preventing mistakes with property declaration order I'm looking for a way to prevent problems in Kotlin with the order of property initialization. One of my biggest loves of Kotlin is all the ways you can lean on the compiler to prevent errors. But in this case it falls flat. Here's an example class Test{ val b = computeB() val a = computeA() private fun computeA() = 4 private fun computeB() = a + 1 } fun main(args: Array) { val a = Test() println("value of b: " + a.b) println("value of a: " + a.a) } In this...