by LordN00b · 1y ago · 0 comments
Second example: that's the point. If the compiler can't prove that x will be initalised before the call it should reject the code until you make it x: number|undefined, to force the closure to handle the undefined case.
val items: MutableList<Int> = mutableListOf(3)
val brokenItems: MutableList<Any> = itemsx is clearly defined to be a number. The compiler should produce an error if the delegate captures x before it has a value assigned.