This isn't a holy war, this isn't a question of "which is better".
What are the pros of using the following format for single statement if blocks.
if (x) print "x is true";
if(x)
print "x is true";
As opposed to
if (x) { print "x is true"; }
if(x) {
print "x is true";
}
If you format your single statement ifs without brackets or know a programmer that does, what led you/them to adopt this style in the first place? I'm specifically interested in what benefits this has brought you.
Update: As the most popular answer ignore the actual question (even if it presents the most sane advice), here's a roundup of the bracket-less pros.
- Compactness
- More readable to some
- Brackets invoke scope, which has a theoretical overhead in some cases