-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Single- vs multiline lambdas #479
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
Comments
👍 I support this change. "Use |
While the switch between |
I would prefer always using |
Yeah, using The question would be 'How many inconsistencies like this we already allow?' either in the style guide (if any) or in the actual language design as @bbatsov points out. |
Is the jury still out on this? Looking here doesn't seem to provide a definitive answer: |
I guess it is. :-) |
Why does this not use the structure of almost every other block in Ruby (i.e. going from |
I think I have to agree with @bbatsov answer here #270 (comment) |
See rubocop/ruby-style-guide#479. Disable Style/Lambda.
See rubocop/ruby-style-guide#479. Disable Style/Lambda.
See rubocop/ruby-style-guide#479. Disable Style/Lambda.
See rubocop/ruby-style-guide#479. Disable Style/Lambda.
For the reasons described in this blog article, I suggest changing the preferred notation for lambda notation, single line and multiline) to stabby lambda ( Additional contextI will paste the relevant content of the article here so it is colocated with this issue: Stabby Notation as an Indicator of Preferred and Default Proc TypeIn a previous article, "lambdas Are Better Than procs", I proposed that lambdas should be used rather than procs in almost all cases, given that they are safer in terms of argument count checking and return behavior. So it makes sense that One way to look at it is, by using the stabby lambda notation, we are
|
Mainly agreeing with the points in the Rubocop discussion [1]: > it is easy to miss the `lambda` and assume it is a normal code block. > The pictorial nature of `->` reduces this risk. [1] rubocop/ruby-style-guide#479 (comment)
The style guide currently says
I disagree. Having to change lambda syntax from
-> {}
tolambda do; end
when a lambda grows too large for one line seems wrong. For multi-line lambdas, I would prefer using the stabby lambda syntax with a curly-brace block:The text was updated successfully, but these errors were encountered: