3 ms·
Now you have the bug occur if someone forgets an equal since this is always true: if (llama = false) So use Yoda conditionals instead: if (false == l
by wting 12y ago
Now you have the bug occur if someone forgets an equal since this is always true:
if (llama = false)
So use Yoda conditionals instead:
if (false == llama)
Is that really an improvement over the original? As I've stated in my sibling reply, you are decreasing human readability for machine readability.
- wtetzner 12y agoMaybe if (llama != true) instead? Or maybe you just use a not function: if (not(llama))
- jobu 12y agoI have seen code that uses the Yoda style, but I think it's a bit overkill. Any C/C++ compiler I've used in the last several years will complain if you do an assignment in a conditional. (Unfortunately I've also seen projects that spew out a slew of compiler warnings under normal circumstances, so YMMV.)