DEV Community

loading...

Discussion on: If (all) else is complicated, switch to switch?

Collapse
branzz profile image
Branzz

Which can, in turn, be simplified by Java 13's Enhanced Switch statement (or even a ternary statement at that point).

console.log(switch(true) {
    case someExpressionA -> "yes";
    case someExpressionB && someExpressionC || someExpressionD -> "nope";
    default -> "maybe";
});
Enter fullscreen mode Exit fullscreen mode
Collapse
jmdejager profile image
🐤🥇 Jasper de Jager Author

Thnx for sharing! Honored to be your first comment 😊😉

Forem Open with the Forem app