Stream.of()
and Optional.of()
as constructors and map()
and flatMap()
as binding functions.Optional.of(5).flatMap(addOne).flatMap(addTwo).equals(Optional.of(5).flatMap(addThree));
collect()
method is called fold in FP terms, which summarizes bunch of values into one.