2024-09-02 17:15:53 +00:00
|
|
|
import java.lang.String;
|
2024-09-04 08:42:11 +00:00
|
|
|
import java.lang.Integer;
|
2024-09-02 17:15:53 +00:00
|
|
|
|
2024-09-04 08:42:11 +00:00
|
|
|
sealed interface List permits LinkedElem, Elem {}
|
2024-09-02 17:15:53 +00:00
|
|
|
|
|
|
|
|
2024-09-04 08:42:11 +00:00
|
|
|
public record LinkedElem<T>(T a,List l) implements List{}
|
|
|
|
public record Elem<T>(T c) implements List{}
|
2024-09-02 17:15:53 +00:00
|
|
|
|
2024-09-04 08:42:11 +00:00
|
|
|
public class GenericRecordSwitchCase {
|
2024-09-02 17:15:53 +00:00
|
|
|
public main(o) {
|
|
|
|
return switch(o) {
|
|
|
|
case LinkedElem(a, Elem(e)) -> a ;
|
2024-09-04 08:42:11 +00:00
|
|
|
case LinkedElem(a, LinkedElem(e, Elem(f))) -> a;
|
2024-09-02 17:15:53 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|