nave@lemmy.zip to Lemmy Shitpost@lemmy.worldEnglish · 2 years agoI wishi.imgur.comimagemessage-square185linkfedilinkarrow-up1919arrow-down117
arrow-up1902arrow-down1imageI wishi.imgur.comnave@lemmy.zip to Lemmy Shitpost@lemmy.worldEnglish · 2 years agomessage-square185linkfedilink
minus-squaremryessir@lemmy.sdf.orglinkfedilinkarrow-up4·2 years agoPlease elaborate. When and why would his suggestion be worse?
minus-squaremellejwz@lemmy.worldlinkfedilinkEnglisharrow-up1arrow-down2·2 years agoIt will check all of the if statements instead of stopping at the first match.
minus-squaremellejwz@lemmy.worldlinkfedilinkEnglisharrow-up2·2 years agoMy bad, I looked over the returns. If you return something there wouldn’t be much difference between both.
minus-squareCosmicomical@lemmy.worldlinkfedilinkarrow-up1·2 years agoOk just to clarify this was a joke. It was just a pedantic improvement on a deranged solution. The only sensible way to do this is with % 2 or with bitwise operations imo.
minus-squareValmond@lemmy.mindoki.comlinkfedilinkarrow-up1·2 years agoYeah gotta store the return value in a variable!
Please elaborate. When and why would his suggestion be worse?
It will check all of the if statements instead of stopping at the first match.
Each clause already returns
My bad, I looked over the returns. If you return something there wouldn’t be much difference between both.
Ok just to clarify this was a joke. It was just a pedantic improvement on a deranged solution. The only sensible way to do this is with % 2 or with bitwise operations imo.
Yeah gotta store the return value in a variable!