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-squarespartanatreyu@programming.devhexbear4·edit-21 year agoAre you sure? Your C# example: var output = input switch { null => "Null", 0 => "Zero", > 0 => "Positive", _ => "Negative" }; JS proposal for match: const output = match input { when null: "Null"; when 0: "Zero"; if input > 0: "Positive"; default: "Negative"; } linkfedilink
minus-squareJakenVeina@lemm.eehexbear1·1 year agoAha, yeah, I see it now. Looking forward to it. linkfedilink
Are you sure?
Your C# example:
var output = input switch { null => "Null", 0 => "Zero", > 0 => "Positive", _ => "Negative" };
JS proposal for match:
const output = match input { when null: "Null"; when 0: "Zero"; if input > 0: "Positive"; default: "Negative"; }
Aha, yeah, I see it now. Looking forward to it.