forked from JavaTX/JavaCompilerCore
41 lines
863 B
Java
41 lines
863 B
Java
import java.lang.Integer;
|
|
import java.lang.String;
|
|
import java.lang.Boolean;
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
/* boolean enclosedPattern(){
|
|
var i = "Test";
|
|
var j = switch(i){
|
|
case (String s)->{ yield 0;}
|
|
case Integer i ->{ yield 1;}
|
|
};
|
|
return (j==0);
|
|
} */
|
|
} |