[Experimental] Compiler: replace &->proc
with block
#9197
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this PR
For example before this PR you can do:
That's passing the method
File.exists?(String)
as a block argument tofind
.However, having to specify the type is a bit redundant: we already know that the block arg is a string, and that it's just one argument.
One can also write:
which is the same. However, one has to mention
arg
.After this PR
This PR essentially rewrites lets you write this:
and it just works. It gets rewritten to:
It adds as many arguments to the call as expressions are yielded in
find
(or any other method).This also works with
&->foo
and&->obj.foo
. For example (probably not a nice example :-P):Why experimental?
Because I don't know if it's intuitive.
What do you think?
Why are you sending this?
I see in gitter a lot of people use
&->
, and having to specify the types is not nice.Well... mmm... maybe it's just Kai Leahy that does that, I don't know 😊