Timeline for Best practice on if/return
Current License: CC BY-SA 3.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 20, 2012 at 10:56 | history | made wiki | Post Made Community Wiki by DPD | ||
Jul 19, 2012 at 19:28 | comment | added | José Valente | They are also what the OP was explaining in his examples. Just following the line of the question | |
Jul 19, 2012 at 17:37 | comment | added | Adnan |
Your two cases are only equivalent if do something includes a return. If not, the second code will execute do somethingelse regardless of the if predicate which is not how the first block works.
|
|
Jul 19, 2012 at 14:38 | comment | added | kevin cline | If a method is so long that the second form is hard to understand, it is too long. | |
Jul 19, 2012 at 13:15 | history | answered | José Valente | CC BY-SA 3.0 |