Issue #14625 has been reported by irohiroki (Hiroki Yoshioka).

----------------------------------------
Feature #14625: yield_self accepts an argument, calling to_proc
https://bugs.ruby-lang.org/issues/14625

* Author: irohiroki (Hiroki Yoshioka)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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.

~~~ ruby
result = collection
  .yield_self(&method(:filter1))
  .yield_self(&method(:filter2))
~~~


Of course, we can get the same result with

~~~ ruby
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.

~~~ ruby
result = collection
  .yield_self(method :filter1)
  .yield_self(method :filter2)
~~~





-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>