Daniel Holle
b7979ac7e7
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 7m41s
25 lines
439 B
Java
25 lines
439 B
Java
import java.lang.String;
|
|
import java.lang.Integer;
|
|
|
|
sealed interface List permits LinkedElem, Elem {}
|
|
|
|
|
|
public record LinkedElem<T>(T a,List l) implements List{}
|
|
public record Elem<T>(T c) implements List{}
|
|
|
|
public class GenericRecordSwitchCase {
|
|
public main(o) {
|
|
return switch(o) {
|
|
case LinkedElem(a, Elem(e)) -> a ;
|
|
case LinkedElem(a, LinkedElem(e, Elem(f))) -> a;
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|