philnash@programming.dev to JavaScript@programming.dev • 11 months agoStop nesting ternaries in JavaScriptexternal-linkmessage-square17 fedilinkarrow-up121
arrow-up121external-linkStop nesting ternaries in JavaScriptphilnash@programming.dev to JavaScript@programming.dev • 11 months agomessage-square17 Commentsfedilink
minus-squareJakenVeina@lemm.eehexbear2·edit-211 months 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" };