nave@lemmy.zip to Lemmy Shitpost@lemmy.worldEnglish · 1 year agoI wishi.imgur.comexternal-linkmessage-square179fedilinkarrow-up1916arrow-down118
arrow-up1898arrow-down1external-linkI wishi.imgur.comnave@lemmy.zip to Lemmy Shitpost@lemmy.worldEnglish · 1 year agomessage-square179fedilink
minus-squareSkyline969@lemmy.calinkfedilinkEnglisharrow-up67·edit-21 year agoWow. Amateur hour over here. There’s a much easier way to write this. A case select: select(number){ case 1: return false; case 2: return true; } And so on.
minus-squarerobotica@lemmy.worldlinkfedilinkarrow-up13·edit-21 year agoDon’t forget that you can have fall-through cases, so you can simplify it even further: switch (number) { case 1: case 3: case 5: case 7: case 9: ...
Wow. Amateur hour over here. There’s a much easier way to write this.
A case select:
select(number){ case 1: return false; case 2: return true; }
And so on.
Don’t forget that you can have fall-through cases, so you can simplify it even further:
switch (number) { case 1: case 3: case 5: case 7: case 9: ...
Teach me