does anyone know if there is a simpler version to ...
# random
n
does anyone know if there is a simpler version to do grouping ? like a single selector returning a pair ?
Copy code
val map: Map<String, List<String>> = (0 until versions.length).map { i ->
        val versionNode = versions.item(i)
        val version = versionNode.textContent
        val mcVersion = version.substringBefore('-')
        val forgeVersion = version.substringAfter('-')
        mcVersion to forgeVersion
}.groupBy(
        keySelector = {it.first},
        valueTransform = {it.second}
)
t
try zip maybe
n
but that would result in a list of pairs right ? and would require another step to turn it into a map what i want is a
Map<String, List<String>>
s
(0 until 100).fold(mutableMapOf<String, List<String>>()) { acc, i -> val mcVersion = i.toString() val forgeVersion = (i * 2).toString() acc.also { it[mcVersion] = (it[mcVersion] ?: listOf()) + listOf(forgeVersion) } }
dont think it's any cleaner