I'm missing something here, and I cannot find the solution on my own, it seems (at least not within reasonable time).
I'm trying to create a 2-dimensional List, using MutableList, since each entry contains a string, an int and a boolean.
I'm creating the list entries conmtaining the data like this:
var workEntry = mutableListOf("Knus og Knask AS", 100, true)
Then I try creating a list of that object and more of the same:
var work = mutableListOf(mutableListOf("Knus og Knask AS", 100, true), mutableListOf("Del og Hel", 20, false))
That seems to work, sort of...
However, if I access the list elements, I'm unable to access them like this:
[x][x]
If I access the first level list, it contains all the elements of the entry:
var x = work[0].toString() -> This yields [Knus og Knask AS, 100, true]
But this doesn't work:
var y = work[0][0].toString() <--- the second [0] doesn't exist.
Why is this? What am I missing? The reason I want a 2-d List is to access each element like in a table. I don't want to use any string logic for separating the elements in the "row".
Even simpler:
var temprow = mutableListOf("a", 10, true)
var temptable = mutableListOf<Any>(temprow)
var a1 = temptable[0][0] -> yields "Unresolved reference....No get method providing array access.
As long as people are voting down, or voting to close, the question without offering as much as a comment, no answers will be upvoted or accepted for this question. Those who've been helpful may thank those people for not getting their cred.
I'm answering this question myself, in answer to those who are voting down the question, or even to CLOSE it (!), without having the decency or personal integrity to comment on it.
This is a huge problem with StackOverflow. There is absolutely no good reason why you should be able to vote down something without having to post a comment.