ReferenceError: HELL is not defined
by in CodeSOD on 2026-11-25David came across some Java code. This particular block needed to, based on an integer masquerading as an enumerated type, return an amount of time to sleep. It has strong opinions about what should happen when you send it an invalid value:
private static int getTime(int mode) {
return switch (mode) {
case 0 -> 30 * SECOND;
case 1 -> 15 * SECOND;
case 2 -> 10 * SECOND;
case 3 -> 20 * SECOND;
case 4 -> 17 * SECOND;
case 5 -> 32 * SECOND;
default ->
// go to hell
1000000000;
};
}