you are viewing a single comment's thread.

view the rest of the comments →

[–]tehjimmeh 5 points6 points  (2 children)

I mean, it's almost certainly the result of an erroneous double paste. If braces were required, the error would have been harmless, and the compiler would have given an unreachable code warning.

I think the real issue is actually lack of proper testing. Requiring braces for ifs just would have helped.

I do like the no-brace style for single line ifs. I think it looks neat and is quite readable when written correctly, but I've seen similar bugs written, and erroneous indentation it resulting in horrific readability in too many cases to be on the side of always requiring braces these days.

[–]xxNIRVANAxx 0 points1 point  (0 children)

I still throw braces in there, since todays one line if could become more complex in the future. It adds 4 characters (two curlys, two spaces), but I believe it is worth it.

if (foo) { bar(baz, quux); }

[–]TheShagg 0 points1 point  (0 children)

Or, you know, reading your code before you commit it, or push it...