Quantcast
Channel: Why should Java 8's Optional not be used in arguments - Stack Overflow
Viewing all articles
Browse latest Browse all 29

Answer by Steve B. for Why should Java 8's Optional not be used in arguments

$
0
0

This seems a bit silly to me, but the only reason I can think of is that object arguments in method parameters already are optional in a way - they can be null. Therefore forcing someone to take an existing object and wrap it in an optional is sort of pointless.

That being said, chaining methods together that take/return optionals is a reasonable thing to do, e.g. Maybe monad.


Viewing all articles
Browse latest Browse all 29

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>