Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

16
  • I don't think I should directly return the results of action1 and action2 in my case, but that's certainly worth considering in other cases, I hadn't even thought about that. Commented Sep 28, 2016 at 8:52
  • I would assume your functions currently return nothing? Or are you just ignoring what they return because they're not relevant to the operation? Commented Sep 28, 2016 at 9:23
  • @Nelson I'm working on a phonegap plugin, the functions call a bridge to a native API, so it's all a bit more complicated than that Commented Sep 28, 2016 at 9:47
  • As a counterpoint, I would used option 1 because it provides a single return which means a single place to breakpoint before the function exists when using a debugger. Commented Oct 24, 2022 at 20:59
  • @MikeSchinkel, for quite a long time, having a single return from a function/method and thus having to work around this "limitation" is a pattern people have been abandoning, because it introduces cluttered code and the requirement to store or remember the "return" variable value, which worsens readability. In most cases, having a single return is much worse than returning directly. Your debugger argument: you can just as easily place the break point at the place which calls the method with multiple returns to get the same result. I am sorry, your advice is bad in most circumstances. Commented Oct 26, 2022 at 6:22