-
Notifications
You must be signed in to change notification settings - Fork 23
flatMap
Jichao Ouyang edited this page Feb 24, 2016
·
5 revisions
flatMap is simply flatten compose map
imaging when you
- map an Array
[1,2,3]with functionx=>[x], you'll get[[1],[2],[3]] -
flattenwill flatten the nested array into a flat array[1,2,3]
same thing happen to Stream
- map
--1--2--3-->with functionx=>Stream(x)will return--S(1)--S(2)--S(3)--> -
flattenwill flatten the nested Stream into flat Stream--1--2--3-->