Don't mix comparison (==) with assignment (=)
When using comparisons always put your constants on the left. This practice will help you avoid mixing comparison (==) with assignment (=) and will save you hours of clueless debugging.
Recommended:
if (null == $var) {}
if (15 == $number) {}
Not recommended:
if ($var == null {}
if ($number == 15) {}
Bad (!!):
if ($var = null {}
if ($number = 15) {}
This is something you might find a bit hard to get use to, but at the end should probably pay off.
Written by Eldad Fux
Related protips
1 Response
It doesn't concern Java. Anyway it's good to place a constant on the left to avoid NPEs.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Filed Under
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#