@NonNull static fun <A : Any!, B : Any!> flatMap(@NonNull iterable: MutableIterable<A>, @NonNull mapper: (A) -> MutableIterable<B>!): MutableIterable<B>
Returns an iterable consisting of elements that were mapped with a function that is capable of returning an iterable. As the method is working directly with an iterable it needs to create one, thus it returns an ArrayList
as an Iterable
. If you want to get a different type please use Iterables#flatMap(Iterable, Supplier, Function1)
method instead.
iterable
- MutableIterable<A>: elements that should be mapped
mapper
- (A) -> MutableIterable<B>!: function that performs mapping of elements
- type of the elements of the given iterable
- type of the elements of the resulting iterable
Return
MutableIterable<B>: iterable containing mapped elements
@NonNull static fun <A : Any!, B : Any!, C : MutableCollection<B>!> flatMap(@NonNull iterable: MutableIterable<A>, @NonNull supplier: Supplier<out C>, @NonNull mapper: (A) -> MutableIterable<B>!): C
Returns an iterable consisting of elements that were mapped with a function that is capable of returning an iterable.
iterable
- MutableIterable<A>: elements that should be mapped
supplier
- Supplier<out C>: supplier capable of returning the resulting iterable
mapper
- (A) -> MutableIterable<B>!: function that performs mapping of elements
- type of the elements of the given iterable
- type of the elements of the resulting iterable
- Type of collection to be returned
Return
C: collection containing mapped elements