▲ | tomsmeding 4 days ago | |
> Not sure about C#, but in Java if you write `sealed` correctly you won't need the catch-all throw. Will the compiler check that you have handled all the cases still? (Genuinely unsure — not a Java programmer) | ||
▲ | ackfoobar 4 days ago | parent | next [-] | |
Yes https://openjdk.org/jeps/409#Sealed-classes-and-pattern-matc... > with pattern matching for switch (JEP 406)the compiler can confirm that every permitted subclass of Shape is covered, so no default clause or other total pattern is needed. The compiler will, moreover, issue an error message if any of the three cases is missing | ||
▲ | brabel 4 days ago | parent | prev [-] | |
Yes, that's the whole purpose of marking an interface/class `sealed`. |