forked from JavaTX/JavaCompilerCore
41 lines
867 B
Java
41 lines
867 B
Java
import java.lang.Integer;
|
|
import java.lang.String;
|
|
import java.lang.Object;
|
|
|
|
class SwitchStatement {
|
|
|
|
boolean switchStandard(){
|
|
str = "SwitchMe";
|
|
switch(str){
|
|
case String s: return true;
|
|
default: return false;
|
|
}
|
|
}
|
|
|
|
boolean switchInteger(){
|
|
i = 5;
|
|
switch(i){
|
|
case Integer j:
|
|
case String s: i = 6; break;
|
|
default: i = 0; break;
|
|
}
|
|
return (i==0);
|
|
}
|
|
|
|
boolean guardedPattern(){
|
|
var i = 1;
|
|
switch(i){
|
|
case Integer j && j == 1: return true;
|
|
default: return false;
|
|
}
|
|
}
|
|
|
|
record Coordinates(double x, double y) {}
|
|
|
|
boolean recordPattern(Object obj){
|
|
switch(obj){
|
|
case Coordinates(double lat, double lon): return true;
|
|
default: return false;
|
|
}
|
|
}
|
|
} |