DEV Community

Discussion on: Save the Optional, stop using isPresent

Collapse
 
koenighotze profile image
David Schmitz

Good point, thank you. I have added a small extra sentence, that hopefully reduced the confusion.

To add to your answer: flatMap expects a mapper that returns an Option. map on the other hand wraps the result of the applied mapper function into either some or none.

In short: map creates a new "Gift Box" and flatMap reuses the "Gift Box".