View Single Post
Old 06-11-2019, 10:17 AM   #1041
pazos
cosiņeiro
pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.
 
Posts: 1,406
Karma: 2451781
Join Date: Apr 2014
Device: BQ Cervantes 4
It is a bad practice because a) it isn't needed and b) can cause problems if someone adds a n+1 element to the returned table.

It is like in C, where
Code:
if(something) return true; else return false;
is valid but a bad practice because in the moment of extending one of the statements it will become non-valid.

So unless you're sure that you always want a single return statement then the following is recommended
Code:
if(something) {return true;} else {return false;}
We can argue that braces are not needed in this particular example, like the comma in your sample case.
pazos is offline   Reply With Quote