17 lines
411 B
Plaintext
Raw Normal View History

2023-08-01 14:02:19 +02:00
import java.lang.Integer;
import java.lang.Object;
import java.lang.Float;
record Rec(Integer a, Object b) {}
public class Switch {
2023-08-17 09:27:24 +02:00
main(o) {
2023-08-01 14:02:19 +02:00
return switch (o) {
case Rec(Integer a, Integer b) -> a + b;
case Rec(Integer a, Float b) -> a + 10;
case Rec(Integer a, Rec(Integer b, Integer c)) -> a + b + c;
case Integer i -> i;
default -> 0;
2023-08-01 14:02:19 +02:00
};
}
}