Actions
Feature #14821
closedaditional arguments to yield_self
Status:
Rejected
Assignee:
-
Target version:
-
Description
Currently, yield_self
only accepts a block as its single argument. I propose that it should also accept a series of additional arguments that get passed to the block after self
This is what I mean:
def yield_self(*args, &block)
block.call(self, *args)
end
which would allow writing code like this
some_object.yield_self(:name, :surname, &sort_stuff).do_more_stuff()
instead of code like this
some_object.yield_self{|x| sort_stuff.call(x, :name, :surname).do_more_stuff()
This 1) is shorter 2) expresses intention rather than implementation.
Updated by duerst (Martin Dürst) over 6 years ago
- Tracker changed from Bug to Feature
- Backport deleted (
2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN)
This is clearly a feature, so I have changed it from bug to feature.
The usage examples are still a bit abstract, some more concrete examples would be desirable.
Updated by matz (Yukihiro Matsumoto) over 6 years ago
- Status changed from Open to Rejected
Updated by matz (Yukihiro Matsumoto) over 6 years ago
Your proposal makes the specific case simpler like your example, but in general, it makes the intention of yield_self
(or then
) less clear.
Matz.
p.s.
I removed the previous comment because I made mistake.
Actions
Like0
Like0Like0Like0