Noob to Kotlin. I have a hashmap and which would hold an array for one of it's keys. However when I read the value for that key, Kotlin is not recognizing it as an array.
My hashmap:
var myHashMap = hashMapOf("test" to arrayOf<HashMap<String, Any>>())
Reading the array:
var testString = "__ ${myHashMap["test"].count()} __"
I am getting type mismatch error when I try to read the value. I am storing the array in hashmap in incorrect way?
My hashmap is of type HashMap. I am just specifying the type for the value now and will be storing the actual values dynamically later.
So later when I read myHashMap["test"], I would be expecting something like ["Hello": "World", "ABC": 3]
Edit: Adding my solution
I tried this and it worked for now, but checking if there is a better solution.
var tests = task["test"] as ArrayList<HashMap<String, Any>>
var testCount = tests.count()
Also if I want to keep adding values to myHashMap["test"] for now I am storing the existing values into var, adding new onto it and then passing it out to myHashMap["test"].
tests.add(someHashMap)
myHashMap["test"] = tests
Any quicker way to achieve this?