CTO, coder, and architect at Senacor Technologies in Germany. Coding in Java, JavaScript, Go, whatever gets the job done. Get in touch via @koenighotze on Bluesky.
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".
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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 anOption
.map
on the other hand wraps the result of the applied mapper function into eithersome
ornone
.In short:
map
creates a new "Gift Box" andflatMap
reuses the "Gift Box".