<Kotlin array initialization throws null pointer e...
# stackoverflow
u
Kotlin array initialization throws null pointer exception I'm a total beginner with kotlin, and I'm trying to initialize an array using the constructor that accepts a size and a function. This is what I have: var ary = Array(5, {x -> x + 2}) println(ary[2]) But it's throwing a null pointer exception on the first line. Why is this happening?