Quote:
Originally Posted by oo_jazz_oo
I dont see a huge problem in using one line codes without brackets for certain instances.
PHP Code:
function check(x, y) {
if (x == y) return true;
}
Like in that instance. Does it really make it any more readable...any more efficient...any more anything by adding the brackets?
|
Bad example because if you're going to take shortcuts, take the best shortcut.
PHP Code:
function check(x, y) {
return temp.x == temp.y;
}
In general, I try to always include brackets for one-line statements. Consistency not only improves readability (imo), but it makes your code a lot less error-prone.
If you start saying "oh, well in this instance is it really a problem?" your styling is probably very confusing and inconsistent, and you're much more likely to **** up.