Timeline for Single statement if block - braces or no?
Current License: CC BY-SA 3.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 31, 2014 at 18:52 | comment | added | Peter Mortensen | The one-liner does not work with most debuggers (it is not possible to trigger a break when the content of the 'if' clause is about to be executed). | |
| Dec 30, 2013 at 23:33 | comment | added | Ben Lee | I like ruby's approach here. It offers the perl style single-line <statement> if <condition> or a multiline block style if <condition> / <do something> / end (ruby avoids braces, so here the opening brace is implied by if and the end brace is replaced by a literal end). It doesn't even offer the weird multiline-but-really-just-single-line if statement. | |
| Nov 29, 2013 at 9:21 | history | edited | Peter Mortensen | CC BY-SA 3.0 | Copy edited. Added some context. Removed meta information. |
| Sep 9, 2011 at 7:02 | history | made wiki | Post Made Community Wiki by user36294 | ||
| Nov 6, 2010 at 7:40 | comment | added | Christian Mann | I wonder if anyone's made a Perl program generator just by hooking up /dev/random to a Perl interpreter... | |
| Nov 3, 2010 at 20:24 | comment | added | Joe D | I've never seen somebody confuse perl with pseudocode before. Random characters yes, pseudocode - no. | |
| Nov 3, 2010 at 17:33 | comment | added | eswald | My thoughts exactly. If the single statement looks good on a single line after the if clause, I don't use braces. For any other if statement (or any statement that uses multiple lines), I always use braces. In particular, if there's an else clause, each case always has braces. | |
| Nov 3, 2010 at 15:18 | history | edited | rubber boots | CC BY-SA 2.5 | comma added |
| Nov 3, 2010 at 15:13 | history | answered | rubber boots | CC BY-SA 2.5 |