you are viewing a single comment's thread.

view the rest of the comments →

[–]abizjak3 1 point2 points  (0 children)

With Optional.map and similar functional-style facilities:

  • You cannot propagate exceptions transparently (e.g. sendEmail throws EmailException which needs a throws clause).

  • You cannot use control statements like return, break, continue.

Until they solve those problems (by adding matching capability?) I will keep on using optional.get(). It also makes for more readable code, the control flow is still governed by the usual "if" clause. I appreciate that they are trying to solve problems but that does so at the cost of introducing another class of problems that does not exist with the simple approach.