Do we agree that the code below defines an exhaustive switch so no default is necessary ?
sealed interface List permits Cons, Nil { }
record Cons(String value, Object next) implements List { }
enum Nil implements List { NIL }
int size(List list) {
return switch(list) {
case Cons cons -> 1 + size(cons.next);
case Nil.NIL -> 0
};
}
regards,
Rémi
