philnash ( philnash@programming.dev ) to JavaScript@programming.devEnglish · 3 years agoStop nesting ternaries in JavaScriptwww.sonarsource.comexternal-linkmessage-square25linkfedilinkarrow-up126
arrow-up126external-linkStop nesting ternaries in JavaScriptwww.sonarsource.comphilnash ( philnash@programming.dev ) to JavaScript@programming.devEnglish · 3 years agomessage-square25linkfedilink
minus-squarespartanatreyu ( spartanatreyu@programming.dev ) linkfedilinkarrow-up4·3 years 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"; }
minus-squareJakenVeina ( JakenVeina@lemm.ee ) linkfedilinkarrow-up1·3 years agoAha, yeah, I see it now. Looking forward to it.
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.