Hacker News new | past | comments | ask | show | jobs | submit login

To my knowladge the Java library does not although it is fully capable of supporting this. I guess this is just an example of poor implementation. It could have been easily implemented like this

   Optional<X> x = ...;
   switch (status(x)) {
       case SOME: return x.get() * 10;
       case NONE: .... send error ...
   }
Again I really like the matching functionality but as it stands, since it's not included, it's not worth much without it in my opinion.

With match, that cleans up a LOT of code and if the compiler can guarantee no speed or memory hits for doing this it becomes very valuable very quick.

It's one of the reasons I wanted to learn Rust.




Incidentally, Scala discourages using pattern matching in cases like this (pun not intended), preferring the use of combinators (map/flatMap/etc).




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: