this post was submitted on 14 Aug 2025
307 points (96.1% liked)

Programmer Humor

26373 readers
1105 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
 
(page 2) 6 comments
sorted by: hot top controversial new old
[–] ulterno@programming.dev 1 points 1 month ago (2 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?

load more comments (2 replies)
load more comments
view more: ‹ prev next ›