new bee in Kotlin and I am trying to compile a very simple thing. I'd like to initialize an array of lists with one line of code. But I get stuck in always have to uses mutable objects and inserts unto the list.
Here what I have which I don't like. It is too complicated and many lines of code, the array does not need to be mutable in reality. It will be always the same size and same number of elements.
val r0 = arrayListOf<Int>(1, 3, 5, 7)
val r1 = arrayListOf<Int>(10, 11, 16, 20)
val r2 = arrayListOf<Int>(23, 30, 34, 60)
val list: MutableList<ArrayList<Int>> = ArrayList()
list.add(r0)
list.add(r1)
list.add(r2)
That works, but I want something like
val list2: List<ArrayList<Int>> = ArrayList(
arrayListOf<Int>(1, 3, 5, 7),
arrayListOf<Int>(10, 11, 16, 20),
arrayListOf<Int>(23, 30, 34, 60)
)
But this does not compile, not sure why.
thank you.