flatMap<R> method

Iterable<R> flatMap<R>(
  1. Iterable<R> transform(
    1. T
    )
)

Maps each element to an iterable, then flattens one level.

Equivalent to expand, but named flatMap to match Kotlin/Swift/Rx conventions and pair naturally with compactMap.

[1, 2, 3].flatMap((e) => [e, e * 10]); // (1, 10, 2, 20, 3, 30)

Implementation

Iterable<R> flatMap<R>(Iterable<R> Function(T) transform) =>
    expand(transform);