this post was submitted on 14 Aug 2025
274 points (96.3% liked)

Programmer Humor

25705 readers
1392 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] ulterno@programming.dev 2 points 11 hours ago (1 children)

Same as ?

std::optional<bool> role;

if (role.value())
{ std::cerr ("User is admin");}
else if (!role.value())
{ std::cerr ("User is not admin");}
else if (!role.has_value())
{ std::cerr ("User is not logged in");}

Here has_value() should have been checked first, but the JS seems kinda fine.
Which is it?

[–] shape_warrior_t@programming.dev 4 points 6 hours ago (1 children)

a === b returns true if a and b have the same type and are considered equal, and false otherwise. If a is null and b is a boolean, it will simply return false.

[–] ulterno@programming.dev 0 points 1 hour ago

I see, so logically it is fine.
Just not in the context.