Introduce new overloads of flatMap and flatMapTo
- Sequence<T>.flatMap((T) -> Iterable<R>) - Iterable<T>.flatMap((T) -> Sequence<R>) - Array<T>.flatMap((T) -> Sequence<R>) - Map.flatMap((Entry) -> Sequence<R>) KT-34506
This commit is contained in:
@@ -46,6 +46,17 @@ class CollectionTest {
|
||||
assertStaticAndRuntimeTypeIs<List<String>>(foo)
|
||||
}
|
||||
|
||||
|
||||
@Test fun flatMap() {
|
||||
val source = listOf(null, "foo", "bar")
|
||||
val result1 = source.flatMap { it.orEmpty().asSequence() }
|
||||
val result2 = source.flatMap { it.orEmpty().asIterable() }
|
||||
|
||||
val expected = "foobar".toList()
|
||||
assertEquals(expected, result1)
|
||||
assertEquals(expected, result2)
|
||||
}
|
||||
|
||||
/*
|
||||
@Test fun mapNotNull() {
|
||||
val data = listOf(null, "foo", null, "bar")
|
||||
|
||||
Reference in New Issue
Block a user