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
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -290,7 +290,13 @@ object Mapping : TemplateGroupBase() {
specialFor(ArraysOfUnsigned) { inlineOnly() }
doc { "Returns a single list of all elements yielded from results of [transform] function being invoked on each ${f.element} of original ${f.collection}." }
sample("samples.collections.Collections.Transformations.flatMap")
fun sampleClass(f: Family): String = when (f) {
Maps -> "samples.collections.Maps.Transformations"
else -> "samples.collections.Collections.Transformations"
}
sample("${sampleClass(f)}.flatMap")
typeParam("R")
returns("List<R>")
body {