At the very end, this article introducing to new Java 8 Optional
, states that
Optional is not nearly as powerful as Option[T] in Scala (but at least it doesn’t allow wrapping null). The API is not as straightforward as null-handling and probably much slower. But the benefit of compile-time checking plus readability and documentation value of Optional used consistently greatly outperforms disadvantages
I have a very basic knowledge of Scala and I'm getting familiar with Java 8 Optional
, so at a first sight, it's not clear to me what are the differences between the two, if any.
I know, for example, that in Scala I can use pattern matching to test Option
and make my life easier. But, excluding what are the features of Scala's syntax, I would like to know if there's something I can do with Option
in Scala that I cannot do with Optional
in Java.
Hope this is not marked as silly question, but every time I read that 'powerful', question marks fly over my head.