Skip to content

Conversation

@NoelDavies
Copy link

Then when method should be using early returns instead of if/else

Then when method should be using early returns instead of if/else
@browner12
Copy link
Contributor

how does this change anything?

@NoelDavies
Copy link
Author

NoelDavies commented Oct 20, 2017

The else is useless as you're already returning in the initial if statement.

Removing the else improves readability if nothing else. Technically it should be a strict comparison, but that would probably break a lot of code that isn't strictly typed

@browner12
Copy link
Contributor

i'm pretty sure both of these iterations operate identically. i see no reason to change it unless you can find some performance improvement, or precedence in other code

@tillkruss tillkruss changed the title Use early returns in else method [5.6] Use early returns in else method Oct 20, 2017
@robclancy
Copy link
Contributor

This kind of thing has annoyed me in the past but it is usually like this in the framework and just down to code style and nothing more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants