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

Rule request: prefer implicit returns when possible #1194

Closed
marcelofabri opened this issue Jan 15, 2017 · 3 comments
Closed

Rule request: prefer implicit returns when possible #1194

marcelofabri opened this issue Jan 15, 2017 · 3 comments
Labels
rule-request Requests for a new rules.

Comments

@marcelofabri
Copy link
Collaborator

marcelofabri commented Jan 15, 2017

From raywenderlich.com Swift Style Guide


For single-expression closures where the context is clear, use implicit returns:

attendeeList.sort { a, b in
    a > b
}
@marcelofabri marcelofabri added the rule-request Requests for a new rules. label Jan 15, 2017
@jpsim
Copy link
Collaborator

jpsim commented Jan 21, 2017

related to #70 (only use positional arguments in "simple" closures)

@marcelofabri
Copy link
Collaborator Author

While this is related to #70, it's a bit different since we don't need to decide what "simple" means. Implicit returns are only allowed on single-expression closures.

@jpsim
Copy link
Collaborator

jpsim commented Feb 9, 2017

Although it's not always easy to determine if something is a single expression or not. It's not exactly directly determined by number of lines or presence of semicolons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule-request Requests for a new rules.
Projects
None yet
Development

No branches or pull requests

2 participants