this post was submitted on 07 Sep 2023
29 points (69.9% liked)

Programmer Humor

32571 readers
447 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] FooBarrington@lemmy.world 14 points 1 year ago (1 children)

You can go one step further and use the Bang-Bang operator:

!!m

To be read as "Bang! Bang! You're a boolean now!"

[–] alokir@lemmy.world 2 points 1 year ago (1 children)

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.

[–] FooBarrington@lemmy.world 6 points 1 year ago

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) { ... }