As discovered in https://github.com/rmosolgo/graphql-ruby/pull/313:
-> (arg) { ... } and ->(arg) { ... } are supported in Ruby 2+ (notice the space between -> and the parenthesis.-> (arg) { ... } is not supported in Ruby 1.9.3 and the interpreter reports:syntax error, unexpected tLPAREN_ARG, expecting keyword_do_LAMBDA or tLAMBEG (SyntaxError)
-> (arg) {
^
It seems reasonable to me to enforce ->(arg) { ... } in style guides. After all, all examples in Rubocop's doc or your Ruby style guide use this format consistently.
This is very valuable when developing a library that supports both versions 1.9.3 and 2+.
Looking forward to hearing your opinion on that.
While I don't care at all about 1.9.3 compatibility, I agree that we should stick to the style without a space for historical reasons. I have some memory that at one points we added some similar check to RuboCop, but I might be mistaken.
I like the idea of a cop to keep this consistent, but I would like the style to be configurable as I prefer the style with the space.
Fine by me.
I have a working cop for this, and will commit soon.
Most helpful comment
While I don't care at all about 1.9.3 compatibility, I agree that we should stick to the style without a space for historical reasons. I have some memory that at one points we added some similar check to RuboCop, but I might be mistaken.