sorrybookbroke@sh.itjust.works to Programmer Humor@lemmy.mlEnglish · edit-21 year ago"m=!0"... What the hell am I looking at?sh.itjust.worksimagemessage-square12fedilinkarrow-up151arrow-down122
arrow-up129arrow-down1image"m=!0"... What the hell am I looking at?sh.itjust.workssorrybookbroke@sh.itjust.works to Programmer Humor@lemmy.mlEnglish · edit-21 year agomessage-square12fedilink
minus-squareFooBarrington@lemmy.worldlinkfedilinkarrow-up14·1 year agoYou can go one step further and use the Bang-Bang operator: !!m To be read as “Bang! Bang! You’re a boolean now!”
minus-squarealokir@lemmy.worldlinkfedilinkarrow-up2·1 year agoI might be in the minority but I prefer to do it like this: Boolean(m). It’s the same thing but less cool. On the flip side it’s easier to read when you have a line full of operators.
minus-squareFooBarrington@lemmy.worldlinkfedilinkarrow-up6·1 year agoYep, that’s a much better way! It’s like the “goes down to” operator - a neat trick you should never use :) while (i --> 0) { ... }
You can go one step further and use the Bang-Bang operator:
!!m
To be read as “Bang! Bang! You’re a boolean now!”
I might be in the minority but I prefer to do it like this:
Boolean(m)
.It’s the same thing but less cool. On the flip side it’s easier to read when you have a line full of operators.
Yep, that’s a much better way! It’s like the “goes down to” operator - a neat trick you should never use :)
while (i --> 0) { ... }