Add flatMap sample KT-20357

This commit is contained in:
Dmitry Borodin
2019-08-09 21:11:58 +02:00
committed by Ilya Gorbunov
parent 29b25e3901
commit 664d69b752
8 changed files with 41 additions and 0 deletions
@@ -39,6 +39,8 @@ public fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>> {
/**
* Returns a single list of all elements yielded from results of [transform] function being invoked on each entry of original map.
*
* @sample samples.collections.Collections.Transformations.flatMap
*/
public inline fun <K, V, R> Map<out K, V>.flatMap(transform: (Map.Entry<K, V>) -> Iterable<R>): List<R> {
return flatMapTo(ArrayList<R>(), transform)