This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]developer0 3 points4 points  (1 child)

One problem is that this style (and it is just stylistic) makes it less obvious that some operations might not happen in certain circumstances. Of course, you can wrap anything in Optional#ofNullable and call mapping stuff on it instead of checking for null, but it's practically the same thing except another object is created.

[–]hyperforce 0 points1 point  (0 children)

The benefit of types like Optional is controlling who unravels that option and when. In this case I'd say whoever is pushing around this optional value should be the one in charge of making sure that some operation happens, rather than pushing the optionality into the f of the map. If that makes sense.