Pattern Matching in Java 17 and Beyond

preview_player
Показать описание
Pattern Matching is finding its way into Java, one step at a time, along three paths: patterns, switch improvements, sealed classes. This session will explore the recent history, current state, and future evolution of pattern matching in Java.

⎯⎯⎯⎯⎯⎯ Chapters ⎯⎯⎯⎯⎯⎯
00:00 Introduction
00:58 The Back Story
07:49 Type Patterns
10:22 Pattern Matching in Switch
13:18 Deconstruction Patterns
15:11 Guarded Patterns
17:52 Sealed Classes
20:16 Timeline
20:53 Plot Holes
21:26 Happy End
22:49 When should you use this?
25:47 Conclusion

⎯⎯⎯⎯⎯⎯ Resources ⎯⎯⎯⎯⎯⎯

Categories: #Java #Java17 #Development
Рекомендации по теме
Комментарии
Автор

In my view, this is an excellent and pedagogic presentation on the subject at hand. Thank you.

Автор

Very well done and informative. Glad Java got its super switch. Been using similar patterns in Rust, and it does streamline the code pretty well (not to be abused obviously).

JeremyChone
Автор

Should have used a different font like Consolas for code snippets, sometimes it was confusing whether it is a '(' open parenthesis or a '<' open angle bracket. Great video!

bnayagrawal
Автор

The problem at @17:22 can be partially removed if Java adopts "as-patterns" in future versions. Search "Understanding the Haskell as-pattern" for more info. Essentially the as pattern lets you give a name to a variable while also matching its structure. Nice video and good to see what's coming :)

MORETHANOVERGROWN
Автор

Great explanation, a little twisted, but it worked. Thanks

wwhill
Автор

BTW if sealed class is added in partial recompile the switch might not be exhaustive, so a „default: throw new is implied

berndeckenfels
Автор

Both new future and this video are excellent. I just wonder why you did not use term "exhaustive[ness]" when describing eliminating of default case for the switch with sealed classes/interfaces . Also does such switch need to have null case to be exhaustive?

webtel
Автор

Droolz @ deconstruction pattern <wishing hard>

derrickheng
Автор

I remember that in recent video Brian Goetz was talking about using pattern matching for Map::get to handle null values. Any example how it would work?

Redoranish
Автор

6:37 "Math::evaluate"? Is that a typo or am I missing something here?

quintesse
Автор

I know this is a coding video, but I just realized Duke looks like an Among Us character.

Sackthing
Автор

Let’s make that ugly with local assigns :) case Absolute(var n) && (v = eval(n)) < 0 -> v; (BTW in a pure functional Language it’s easy to cache the double eval, so it’s a more used method)

berndeckenfels
Автор

Copy from Scala. Please give credit to Scala

billyean
Автор

ah, java is trying to copy scala now :)

HoDx