Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard let else return as a one liner? #9

Open
mokagio opened this issue Jan 31, 2017 · 7 comments
Open

Guard let else return as a one liner? #9

mokagio opened this issue Jan 31, 2017 · 7 comments

Comments

@mokagio
Copy link
Contributor

mokagio commented Jan 31, 2017

In the codebase we're using two different styles of early returns:

guard condition else { return }

and

guard condition else {
  return
}

We should pick one and stick to it.

@mokagio
Copy link
Contributor Author

mokagio commented Jan 31, 2017

+1 this for the oneliner

@mokagio
Copy link
Contributor Author

mokagio commented Jan 31, 2017

+1 this for the... newliner (?)

@cuteiosdev
Copy link

I think there's a bit of nuance here. When we need to do something as well as return, I think it should be the newline option. When it's just return, it should be the same line as the last guard statement.

@TimKregerIflix
Copy link

Although if we go with newliner it removes the nuance.

@adriaan
Copy link
Contributor

adriaan commented Feb 2, 2017

In defence of newliner: it does make it easier to set breakpoints. (though you could always make it a newliner temporarily if you need to set a breakpoint).

@TimKregerIflix
Copy link

Yeah thats my primary reason @adriaan it just makes it easier when doing complex traces

@mokagio
Copy link
Contributor Author

mokagio commented Feb 2, 2017

I think there's a bit of nuance here. When we need to do something as well as return, I think it should be the newline option. When it's just return, it should be the same line as the last guard statement.

Sure. The code example only has { return } and that was what the question was about. Although I didn't state anywhere 😳 .

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

No branches or pull requests

4 participants