JavaTXCompilerInJavaTX/resources/bytecode/javFiles/Switch.jav

17 lines
476 B
Plaintext
Raw Normal View History

2023-08-01 12:02:19 +00:00
import java.lang.Integer;
import java.lang.Object;
import java.lang.Float;
record Rec(Integer a, Object b) {}
public class Switch {
2023-08-16 15:13:28 +00:00
Integer main(Object o) {
2023-08-01 12:02:19 +00:00
return switch (o) {
case Rec(Integer a, Integer b) -> { yield a + b; }
2023-08-16 15:13:28 +00:00
case Rec(Integer a, Float b) -> { yield a + 10; }
2023-08-01 12:02:19 +00:00
case Rec(Integer a, Rec(Integer b, Integer c)) -> { yield a + b + c; }
case Integer i -> { yield i; }
default -> { yield 0; }
};
}
}