thank you guys for explaining all that :slightly_s...
# getting-started
k
thank you guys for explaining all that 🙂 managed to put it all together and get it working with mapValues
Copy code
errors.mapValues { (_, v) ->
                     when (v) {
                        is String -> listOf(v)
                        is List<*> -> v as List<String>
                        else -> listOf(v.toString())
                    }
                }
👍 1
r
Won't the last case account for the 2nd one as well? Basically doing a
.toString()
on a list of a different type should still get you a list of strings after
listOf()
s
maybe pragmatically, but the type system doesn’t know that this map is really
Map<String, String|List<String>>
r
ah right, makes sense