Actions
Feature #14625
openyield_self accepts an argument, calling to_proc
Status:
Open
Assignee:
-
Target version:
-
Description
Currently, yield_self doesn't accept any argument other than a block.
But there are situations where I would like to pass a method object to yield_self.
e.g.
result = collection
.yield_self(&method(:filter1))
.yield_self(&method(:filter2))
Of course, we can get the same result with
result = filter2(filter1(collection))
but the order of reading/writing doesn't match the order of thinking.
My request is for yield_self to accept a proc-ish object and call to_proc on it so that we can write the code as shown below, which is more readable.
result = collection
.yield_self(method :filter1)
.yield_self(method :filter2)
Actions
Like0
Like0Like0Like0Like0