Hacker News new | ask | show | jobs
by dtech 43 days ago
Kotlin has always had smart-casting in if and when (sort of switch) expressions, which are strictly more powerful than the current version of Java "pattern matching". Both don't do de-structuring which I would consider a basic requirement for pattern matching, but at least Kotlin didn't call it pattern matching.
1 comments

Wait, what do you mean Kotlin smart-casting is more powerful than pattern matching? Like what example?
strictly more powerful than what Java currently calls pattern matching, not nearly as powerful as eg Scala or Haskell
But what example would you have to demonstrate it's more powerful? As a matter of fact, Kotlin smart-cast approach can't tolerate mutability because it can't guarantee safety, yet Java guarantees.