Skip to content
Jichao Ouyang edited this page Feb 24, 2016 · 5 revisions

flatMap is simply flatten compose map

imaging when you

  1. map an Array [1,2,3] with function x=>[x], you'll get [[1],[2],[3]]
  2. flatten will flatten the nested array into a flat array [1,2,3]

same thing happen to Stream

  1. map --1--2--3--> with function x=>Stream(x) will return --S(1)--S(2)--S(3)-->
  2. flatten will flatten the nested Stream into flat Stream --1--2--3-->
Clone this wiki locally