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.

Required fields*

6
  • 14
    The else is a lesser issue, the bigger problem is you are obviously returning two data types out of a single function, which makes the API of the function unpredictable. Commented Dec 10, 2016 at 17:55
  • 3
    E_CLEARLY_NOTADUPE Commented Dec 10, 2016 at 19:00
  • 3
    @DavidPacker: At least two; could be three. -1 is a number, false is a boolean, and value isn't specified here so it could be any type of object. Commented Dec 10, 2016 at 21:53
  • 1
    @Yay295 I was hoping the value is actually an integer. If it can be anything then that's even worse. Commented Dec 10, 2016 at 22:42
  • @DavidPacker This is a very important point, especially when raised with regard to a question about good practices. I agree with you and Yay295, however the code samples serve as an example to demonstrate an unrelated technique of coding. Nevertheless, I keep in mind that this is an important matter and shouldn't be overlooked in actual code. Commented Dec 12, 2016 at 20:21