Flow-sensitive typing: Difference between revisions

Content deleted Content added
No edit summary
WikiCleanerBot (talk | contribs)
m v2.04b - Bot T20 CW#61 - Fix errors for CW project (Reference before punctuation)
Line 87:
It achieves this is in a different way, it allows to match the type of a structure, extract data out of it at the same time by declaring new variable. As such, it reduces the ceremony around type casting and value extraction. Pattern matching works best when used in conjunction with [[algebraic data types]] because all the cases can be enumerated and statically checked by the compiler.
 
See this example mock for future Java versions :<ref>{{cite web |title=Pattern Matching for Java |url=https://cr.openjdk.java.net/~briangoetz/amber/pattern-match.html|website=openjdk.java.net |language=en-us |date=September 2018 |accessdate=1 October 2021 |author=Gavin Bierman and Brian Goetz}}</ref>:
<syntaxhighlight lang="java">
int eval(Node n) {