Post

Triangle Java
Triangle Java@TriangleJava·
1/ Proposed for Java 17: JEP 406: Pattern Matching for switch (Preview). What can we do with these? Read on! openjdk.java.net/jeps/406
English
1
1
3
0
Triangle Java
Triangle Java@TriangleJava·
2/ With pattern matching for switch, we can write code like this, where we test for a type on the left and use it directly on the right without having to cast it ourselves.
Triangle Java tweet media
English
1
1
1
0
Triangle Java
Triangle Java@TriangleJava·
3/ JEP 406 also introduces "guard patterns", kind of like adding an if statement to your switches. This should simplify a lot of switch logic! In this case, Large and Small triangles are defined on the left side of the switch, rather than in an if-statement on the right side.
Triangle Java tweet media
English
0
1
1
0
शेयर करें