开发者生态
morning
Java 密封类和详尽的模式匹配
摘要
【HN用户评论摘要】 Java also has recursive patterns and (maybe still in preview) literal patterns: `switch (x) { case A(B(true, var c)) -> f(c); }` Scala punching the air rn Java continues to try and catch up...
and
Java
patterns
Scala
the
Kotlin
https
sealed
classes
HN用户评论摘要
2026-10-19
1 阅读
约1分钟阅读
hnisjafx40
字号:
【HN用户评论摘要】
Java 还具有递归模式和(可能仍在预览中)文字模式: `switch (x) { case A(B(true, var c)) -> f(c); }`
Scala 打空气 rn
Java 继续尝试追赶 Kotlin
https://kotlinlang.org/docs/sealed-classes.html 当与 C++、Ruby 和 Python 进行比较时,我并不介意 Java。我找不到在 Scala 之后回去的理由(它似乎由于不加区别而失败),尤其是 Kotlin
原始链接:https://neilmadden.blog/2026/04/24/java-sealed-classes-and-exhaustive-pattern-matching/
这篇文章对您有帮助吗?
订阅66必读
每日精选科技资讯,直达你的邮箱