Endless method definition [Feature #16746] - #2996
Conversation
|
Only a one line definition is possible? |
|
Newlines are not significant. |
|
keep syntax simple . compatible . easy to learn . |
66a1b65 to
5f1f0e2
Compare
|
So this also works? def notify(user_id) =
user = User.find user_id
Mailer.notify user
DoSomethingWorker.perform user
p notify(10) |
|
No, the body must be an argument expression. |
|
Thanks! |
|
Here is just a patch. |
I think delimiting that a method is no more than an argument expression actually adds to readability. It's valuable to be able to quickly ascertain when a thing is just the simple variant. As @mame points out, 24% of methods in the Ruby codebase are just an argument expression. It's just a tiny bit of syntax to learn, which seems worth it to eek out a little more quick comprehensibility for this very common case of simple method definition. |
|
Do not discuss spec in this PR. |
5f1f0e2 to
a948d0b
Compare
a948d0b to
e8f5369
Compare
Synopsis
The new method definition syntax proposed by @mame at Feature #16746, then noted by @matz.
As you see, there is no "
end".Examples