bodiam
03/01/2020, 2:23 AMmyMap.mapWithIndex { (index, key, value ) -> .... }
available? I know it's possible with arrays, but I "need" to have an index counter (my current approach is just to have a counter var, but I was hoping there would be something more elegant)deactivateduser
03/01/2020, 2:35 AMbodiam
03/01/2020, 2:55 AMColumn
objects which require a key, a value, and an index. The insertion order etc isn't really important for me, I'm not using the index, it's just a required parameter for the creation of Columnsdeactivateduser
03/01/2020, 3:05 AMdata class Column(var index: Int, var key: String, var value: String)
var myMap = mapOf("a" to "aa", "b" to "bb", "c" to "cc")
var myList = myMap.toList().mapIndexed { index, pair -> Column(index, pair.first, pair.second) }
println(myList)
ilya.gorbunov
03/01/2020, 3:55 AMmap.entries
collection:
map.entries.mapIndexed { index, (key, value) -> Column(index, key, value) }
bodiam
03/01/2020, 4:51 AM