Hacker News new | ask | show | jobs
by groby_b 1783 days ago
Comes from the null==val idiom, and that comes from avoiding the popular "if (val=null)" bug in C/C++.

Sure, we could just admit that assignments in conditions are a permanently stupid idea. Instead, an entire industry backwards the conditions wrote.

1 comments

I find initializing condtions like `if(Type variable = ...)` to be very nice in C++ to avoid excessive nesting while still keeping the variable scoped to the block. Of course, I also enable -Wparentheses for things like `if(val=null)`, which you get e.g. when using -Wall with both GCC and Clang.