3 ms·
> 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 case
by tomsmeding 1y 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 1y agoYes https://openjdk.org/jeps/409#Sealed-classes-and-pattern-matching 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 1y agoYes, that's the whole purpose of marking an interface/class `sealed`.