Timeline for Should "else" be used in situations where control flow renders it redundant?
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 15, 2016 at 13:06 | vote | accept | rhino | ||
| Dec 11, 2016 at 13:01 | history | edited | candied_orange | CC BY-SA 3.0 | added 41 characters in body |
| Dec 10, 2016 at 22:21 | comment | added | candied_orange | @Makyen you raise a good point. One I was trying to ignore. I also believe something should be done after the if to make it clear that this section of code is done and the structure is finished. To do this I do what I haven't done here (because I didn't want to distract from the OP's main point by making other changes). I do the simplest thing I can that achieves all that without being distracting. I add a blank line. | |
| Dec 10, 2016 at 22:01 | comment | added | Makyen | I generally prefer this also, for the reason stated here. However, I usually place a comment at the close of each if block of } //else to make it clear, when reading the code, that the only intended execution after the if code block is if the condition in the if statement was false. Without something like this, particularly if the code within the if block grows to be more complex, it may not be clear to whoever is maintaining the code that the intent was to never execute past the if block when the if condition is true. | |
| Dec 10, 2016 at 21:25 | history | edited | candied_orange | CC BY-SA 3.0 | added 2 characters in body |
| Dec 10, 2016 at 20:40 | history | edited | candied_orange | CC BY-SA 3.0 | added 2 characters in body |
| Dec 10, 2016 at 19:18 | history | edited | candied_orange | CC BY-SA 3.0 | added 5 characters in body |
| Dec 10, 2016 at 17:00 | history | answered | candied_orange | CC BY-SA 3.0 |