Flow-sensitive typing: Difference between revisions

Content deleted Content added
m cite repair;
Tags: Mobile edit Mobile web edit Advanced mobile edit
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=JEP 441: Pattern Matching for Javaswitch| |url=https://cr.openjdk.java.netorg/~briangoetzjeps/amber/pattern-match.html441|website=openjdk.java.netorg |language=en-us |date=19 September 20182023 |access-date=114 OctoberNovember 20212023 |author=Gavin Bierman and Brian Goetz}}</ref>
<syntaxhighlight lang="java">
int eval(Node n) {