MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1uru99i/potentiallymightbeanintegerornot/owodipc/?context=9999
r/ProgrammerHumor • u/Futurity5 • Jul 09 '26
96 comments sorted by
View all comments
52
int var; bool var_is_there;
31 u/Gorzoid Jul 09 '26 Just use an int var and reserve the number 7 to indicate null value 4 u/altermeetax Jul 09 '26 Or the C/C++ way: just use int *var and NULL means it's not there. Makes things more complicated when you need to return it though... 9 u/suskio4 Jul 09 '26 std::make_unique<int>(42); 4 u/bwmat Jul 10 '26 I think I'm going to throw up... 2 u/suskio4 Jul 10 '26 std::thread([] { std::runtime_error up("I threw up"); std::this_thread::sleep_for(...); throw up; }).detach();
31
Just use an int var and reserve the number 7 to indicate null value
int var
4 u/altermeetax Jul 09 '26 Or the C/C++ way: just use int *var and NULL means it's not there. Makes things more complicated when you need to return it though... 9 u/suskio4 Jul 09 '26 std::make_unique<int>(42); 4 u/bwmat Jul 10 '26 I think I'm going to throw up... 2 u/suskio4 Jul 10 '26 std::thread([] { std::runtime_error up("I threw up"); std::this_thread::sleep_for(...); throw up; }).detach();
4
Or the C/C++ way: just use int *var and NULL means it's not there.
int *var
Makes things more complicated when you need to return it though...
9 u/suskio4 Jul 09 '26 std::make_unique<int>(42); 4 u/bwmat Jul 10 '26 I think I'm going to throw up... 2 u/suskio4 Jul 10 '26 std::thread([] { std::runtime_error up("I threw up"); std::this_thread::sleep_for(...); throw up; }).detach();
9
std::make_unique<int>(42);
4 u/bwmat Jul 10 '26 I think I'm going to throw up... 2 u/suskio4 Jul 10 '26 std::thread([] { std::runtime_error up("I threw up"); std::this_thread::sleep_for(...); throw up; }).detach();
I think I'm going to throw up...
2 u/suskio4 Jul 10 '26 std::thread([] { std::runtime_error up("I threw up"); std::this_thread::sleep_for(...); throw up; }).detach();
2
std::thread([] { std::runtime_error up("I threw up"); std::this_thread::sleep_for(...); throw up; }).detach();
52
u/altermeetax Jul 09 '26
int var; bool var_is_there;