Timeline for Should I return from a function early or use an if statement? [closed]
Current License: CC BY-SA 3.0
53 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| S May 18, 2019 at 10:24 | history | notice added | Thomas Owens♦ | Historical significance | |
| S May 18, 2019 at 10:24 | history | locked | Thomas Owens♦ | ||
| Apr 8, 2019 at 2:17 | comment | added | xelber | I really don't know why this is closed. Don't come back with a list of guidelines, caz if this closed because it violate guidelines, then the guidelines needs to change. | |
| Jul 30, 2018 at 6:47 | comment | added | evilReiko | 1- Mostly it's opinion-based & personal flavor preference 2- It depends on what the function returns, for example: A- if function always return a number (or always return an string, or always return a boolean, or doesn't return anything) then multi-exits might be better, B- but if function returns an object (or an array, or different return type for each condition) then nested IFs might be better/easier | |
| Jul 7, 2017 at 16:43 | history | edited | Deduplicator | CC BY-SA 3.0 | added syntax-highlighting |
| May 18, 2017 at 22:38 | comment | added | Zygimantas | And I like opinion based questions and answers. They tell me what majority prefers and that lets me to write the code for others to read. | |
| Oct 13, 2016 at 4:18 | comment | added | gsf | so what if there is no absolute proof in one or another direction? When enough argumentation is provided in one and another direction and there is a voting if the answer is correct - it makes it very useful. I find closing questions like this to be harmful to the value of this site. | |
| Aug 2, 2016 at 21:44 | review | Reopen votes | |||
| Aug 4, 2016 at 10:29 | |||||
| Nov 1, 2015 at 1:31 | history | closed | CommunityBot Bart van Ingen Schenau Ixrec | Opinion-based | |
| Oct 27, 2015 at 15:44 | comment | added | user7433 | now this question is a fine example of an opinion-based question | |
| Oct 27, 2015 at 15:38 | review | Close votes | |||
| Nov 1, 2015 at 1:32 | |||||
| Oct 4, 2015 at 17:00 | history | edited | gnat | edited tags | |
| May 12, 2015 at 12:47 | comment | added | mk7 | There is an unstated assumption in the question's examples and in the answers that we are not considering early return from within loops. They can make reasoning about a function a good deal more complicated, and are harder to brush off as being a harmless convenience. | |
| May 12, 2015 at 9:42 | history | edited | Martin Schröder | retag (since the retag priviledge is gone I have to go through suggested edits) | |
| Jan 24, 2015 at 11:31 | history | tweeted | twitter.com/#!/StackProgrammer/status/558950089184780290 | ||
| Jan 23, 2015 at 20:38 | history | protected | gnat | ||
| Jan 23, 2015 at 19:49 | comment | added | yannis | Related: Where did the notion of"one return only" come from? | |
| Jan 23, 2015 at 19:49 | history | edited | yannis | CC BY-SA 3.0 | ah, the good old days... |
| Jan 23, 2015 at 19:49 | history | reopened | yannis | ||
| Nov 10, 2011 at 1:58 | history | edited | CommunityBot | insert duplicate link | |
| Nov 10, 2011 at 1:58 | history | closed | CommunityBot | exact duplicate | |
| Nov 10, 2011 at 1:57 | history | reopened | CommunityBot | ||
| Sep 26, 2011 at 3:19 | history | closed | Jeff Atwood | not constructive | |
| Sep 26, 2011 at 3:19 | history | notice removed | Jeff Atwood | ||
| Sep 26, 2011 at 3:19 | history | unlocked | Jeff Atwood | ||
| Sep 21, 2011 at 22:37 | history | edited | user8 | CC BY-SA 3.0 | edited tags; edited title |
| Sep 21, 2011 at 22:35 | history | notice added | Adam Lear♦ | ||
| Sep 21, 2011 at 22:35 | history | locked | Adam Lear♦ | ||
| Sep 21, 2011 at 22:35 | history | edited | Adam Lear♦ | edited tags | |
| S Feb 18, 2011 at 13:21 | answer | added | CashCow | timeline score: 12 | |
| S Feb 18, 2011 at 13:21 | history | made wiki | Post Made Community Wiki | ||
| Nov 12, 2010 at 18:49 | answer | added | hasen | timeline score: -1 | |
| Nov 12, 2010 at 18:10 | answer | added | azheglov | timeline score: 9 | |
| Nov 12, 2010 at 12:39 | comment | added | dr Hannibal Lecter | I'm a bit late for this discussion so I won't put this in an answer; I also thought about this two years ago: lecterror.com/articles/view/code-formatting-and-readability I find the second easier to read, modify, maintain and debug. But maybe that's just me :) | |
| Nov 12, 2010 at 2:34 | answer | added | Ming-Tang | timeline score: 0 | |
| Nov 11, 2010 at 23:37 | answer | added | Toto | timeline score: 2 | |
| Nov 11, 2010 at 21:21 | answer | added | Dan Rosenstark | timeline score: 1 | |
| Nov 11, 2010 at 21:06 | vote | accept | Rachel | ||
| Nov 11, 2010 at 20:44 | answer | added | user7197 | timeline score: 23 | |
| Nov 11, 2010 at 20:22 | answer | added | Bobby Tables | timeline score: 6 | |
| Nov 11, 2010 at 20:18 | answer | added | Peter Turner | timeline score: 3 | |
| Nov 11, 2010 at 20:11 | answer | added | Jason Viers | timeline score: 167 | |
| Nov 11, 2010 at 20:04 | answer | added | jolt | timeline score: 1 | |
| Nov 11, 2010 at 19:40 | answer | added | Paul Nathan | timeline score: 8 | |
| Nov 11, 2010 at 19:38 | answer | added | Steven Evers | timeline score: -2 | |
| Nov 11, 2010 at 19:37 | answer | added | Mike Dunlavey | timeline score: -2 | |
| Nov 11, 2010 at 19:31 | answer | added | rjzii | timeline score: 32 | |
| Nov 11, 2010 at 19:27 | answer | added | Mason Wheeler | timeline score: 396 | |
| Nov 11, 2010 at 19:26 | answer | added | nathan | timeline score: 7 | |
| Nov 11, 2010 at 19:26 | answer | added | STW | timeline score: 9 | |
| Nov 11, 2010 at 19:26 | history | edited | rjzii | edited tags | |
| Nov 11, 2010 at 19:22 | answer | added | Josh K | timeline score: 1 | |
| Nov 11, 2010 at 19:20 | history | asked | Rachel | CC BY-SA 2.5 |