this post was submitted on 07 Sep 2023
26 points (68.1% liked)

Programmer Humor

32444 readers
741 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
[–] [email protected] 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!"

[–] [email protected] 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.

[–] [email protected] 7 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) { ... }