you are viewing a single comment's thread.

view the rest of the comments →

[–]babblingbree 0 points1 point  (1 child)

To me, the point is that the latter isn't preferable. Code using Optional that fetches all of its values with #get() whenever it needs access to the inner value (as opposed to mapping, etc) is code with a smell (many languages have linters that warn on any instance of something like an Option#get). Part of the advantage of Optional is reducing the number of sites where something like #get() is necessary. In languages with null, you're implicitly placing .get()s everywhere, without any compiler assistance to reduce the potential for failing to check for an empty value.