mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 20:17:25 +00:00
[jdk13] support for switch expression's yield keyword.
This commit is contained in:
4 files changed
+138
-1
No files matched your search
@@ -0,0 +1,55 @@
|
||||
public class Switch13 {
|
||||
public void basic() {
|
||||
switch (5) {
|
||||
case 1:
|
||||
case 2:
|
||||
System.out.println("OK");
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
public void multiCase() {
|
||||
switch (5) {
|
||||
case 1, 2:
|
||||
System.out.println("OK");
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
public int switchExpr1() {
|
||||
return switch (5) {
|
||||
case 1, 2 -> 0;
|
||||
case 3 -> {
|
||||
yield 10;
|
||||
}
|
||||
default -> 10;
|
||||
} + 10;
|
||||
}
|
||||
|
||||
public int switchExpr2() {
|
||||
return switch (5) {
|
||||
case 1, 2:
|
||||
System.out.println("Hello");
|
||||
case 3:
|
||||
yield 10;
|
||||
default:
|
||||
yield 20;
|
||||
} + 10;
|
||||
}
|
||||
|
||||
public void arrowSwitch() {
|
||||
switch (5) {
|
||||
case 1, 2 -> System.out.println("Hello");
|
||||
case 3 -> {
|
||||
System.out.println("");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void emptySwitch() {
|
||||
switch (5) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user