flatMap<A, B> function
- NonEmptyList<
B> f(- A
Maps over the items of the NonEmptyList using function f
, then flattens the result.
var nel = NonEmptyList([1, 2, 3]);
print(flatMap<int, int>((i) => NonEmptyList([i, i * 10]))(nel).items); // [1, 10, 2, 20, 3, 30]
Implementation
NonEmptyList<B> Function(NonEmptyList<A>) flatMap<A, B>(
NonEmptyList<B> Function(A) f) =>
(NonEmptyList<A> list) =>
NonEmptyList(list._items.expand((item) => f(item)._items).toList());