ngn@lemy.lol to Programmer Humor@lemmy.mlEnglish · 7 months agogot himlemy.lolimagemessage-square26fedilinkarrow-up15arrow-down10
arrow-up15arrow-down1imagegot himlemy.lolngn@lemy.lol to Programmer Humor@lemmy.mlEnglish · 7 months agomessage-square26fedilink
minus-squarelseif@sopuli.xyzlinkfedilinkarrow-up0·7 months agoi personally find this a lot less readable than the switch example. the case keywords at the start of the line quickly signify its meaning, unlike with => after the pattern. though i dont speak for everybody.
minus-squareDoods@infosec.publinkfedilinkarrow-up0arrow-down1·edit-27 months agoHow about this one? it more closely mirrors the switch example: match suffix { 'G' | 'g' => mem -= 30, 'M' | 'm' => mem -= 20, 'K' | 'k' => mem -= 10, _ => {}, } How about this other one? it goes as far as cloning the switch example’s indentation: match suffix { 'G' | 'g' => { mem -= 30; } 'M' | 'm' => { mem -= 20; } 'K' | 'k' => { mem -= 10; } _ => {}, }
i personally find this a lot less readable than the
switch
example. thecase
keywords at the start of the line quickly signify its meaning, unlike with=>
after the pattern. though i dont speak for everybody.How about this one? it more closely mirrors the switch example:
match suffix { 'G' | 'g' => mem -= 30, 'M' | 'm' => mem -= 20, 'K' | 'k' => mem -= 10, _ => {}, }
How about this other one? it goes as far as cloning the switch example’s indentation:
match suffix { 'G' | 'g' => { mem -= 30; } 'M' | 'm' => { mem -= 20; } 'K' | 'k' => { mem -= 10; } _ => {}, }