KaKi87@jlai.lu to JavaScript@programming.dev · edit-22 months agoTernary-based pattern matching in JSlemmyverse.linkexternal-linkmessage-square6linkfedilinkarrow-up16arrow-down10
arrow-up16arrow-down1external-linkTernary-based pattern matching in JSlemmyverse.linkKaKi87@jlai.lu to JavaScript@programming.dev · edit-22 months agomessage-square6linkfedilink
minus-squarechickenf622@sh.itjust.workslinkfedilinkarrow-up5·3 months agoThis is probably just my general dislike of chained ternary operators, but why not just write this out the “long” way to make intention clearer?
minus-squaretowerful@programming.devlinkfedilinkarrow-up1·3 months agoYeh, I’d just do early return. It’s not much more typing, and I find it easier to read and navigate specific conditional paths. Some built in pattern matching would be cool (like the when keyword), but I’m not going to force it into my code
minus-squareKaKi87@jlai.luOPlinkfedilinkarrow-up1·3 months agoProbably just my general dislike of verbosity 😅
This is probably just my general dislike of chained ternary operators, but why not just write this out the “long” way to make intention clearer?
Yeh, I’d just do early return.
It’s not much more typing, and I find it easier to read and navigate specific conditional paths.
Some built in pattern matching would be cool (like the when keyword), but I’m not going to force it into my code
Probably just my general dislike of verbosity 😅