Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In Java 18, this is the pattern matching you're talking about.

`if (o instanceof String s) {`

Not much benefits over Kotlin's smart casts.

Guarded patterns with this version of pattern matching should be translatable to adding another "and" condition. The Kotlin compiler should have no problem reasoning with that.

---

I find positional destructuring in Scala (which works similarly in Java 19) a bad design.

https://news.ycombinator.com/item?id=31399737



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

Search: