Core concept
String day = switch (num) {
case 1, 2, 3 -> "early";
case 4, 5, 6 -> "mid";
default -> "unknown";
};Advertisement
How it works
Coexists with traditional switch statements. yield for multi-line branches.
Advertisement
Trade-offs + gotchas
Replacing enum switch. Value-returning selection.