philnash@programming.dev to JavaScript@programming.dev • 1 year agoStop nesting ternaries in JavaScriptexternal-linkmessage-square17 fedilinkarrow-up121
arrow-up121external-linkStop nesting ternaries in JavaScriptphilnash@programming.dev to JavaScript@programming.dev • 1 year agomessage-square17 Commentsfedilink
minus-squareJakenVeina@lemm.eehexbear2·edit-21 year agoYeah, a switch expression is different than a switch statement. I'm not actually sure how many languages actually have them, but in C# its... var output = input switch { null => "Null", 0 => "Zero", > 0 => "Positive", _ => "Negative" }; linkfedilink
Yeah, a switch expression is different than a switch statement. I'm not actually sure how many languages actually have them, but in C# its...
var output = input switch { null => "Null", 0 => "Zero", > 0 => "Positive", _ => "Negative" };