News for hackers. Stuff that matters.
Re:When are enums not a code smell? by dwaltrip on Monday November 22, 2021 @01:22PM (#29309823)
If I’m understanding correctly, languages like rust avoid that problem by throwing a compile error when a match statement doesn’t cover all possible cases.

Of course, a catch-all would then somewhat reintroduce the problem.

Re:When are enums not a code smell? by aardvark179 on Monday November 22, 2021 @04:14PM (#29311640)
Yes. The problem you then have is that adding additional values to the enum then either breaks compatibility or relaxes that guarantee. Since Java tries to run old code for as long as possible the only option for switch statements is to ensure there is a fallback so that you at least know there is a problem.