Add sample for Map.flatMap

This commit is contained in:
Dmitry Borodin
2020-04-12 01:04:08 +02:00
committed by Ilya Gorbunov
parent 1a0b59da49
commit dd46d5ca5a
3 changed files with 14 additions and 4 deletions
@@ -353,7 +353,11 @@ class Maps {
assertPrints(peopleToAge.map { it.value }, "[20, 21]")
}
@Sample
fun flatMap() {
val map = mapOf("122" to 2, "3455" to 3)
assertPrints(map.flatMap { (key, value) -> key.take(value).toList() }, "[1, 2, 3, 4, 5]")
}
}
}