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?
|
On first site I would say it was a mistake, and fix it to have brackets..
I agree not to teach like this, but if you are the only one ever going to touch your scripts.. I suppose it doesn't matter if it works for you.. lol
But if someone in the future may have to go over it.. Again it could confuse them... I'm not totally experienced in programming, so I don't know, others may be able to pick it up what it means faster.. Even if I did pick it up, I'd take the time to fix it towards a common style for others and myself in case I look at it again in the future.
Quote:
Originally Posted by salesman
PHP Code:
function check(x, y) { return temp.x == temp.y; }
|
This would return true if true? and if it isn't the same, it would still return false?
I'm only wondering because I would do:
this.variable = 0;
if (this.variable == 1){
dostuff();
}
I use 0 and 1.. and later on if I need to I can increase it if I want it to be 2, 3, or 4.. but even if it stays on and off, true or false, I still use 0 and 1.. should I start doing true and false for those special things that only use true or false?