
Issue #18690 has been updated by rubyFeedback (robert heiler). I do not have any strong opinions either way, but Benoit wrote:
The last example is just:
p.call(honyarara, fugafugafuga, hogehogehoge)
isn't it? And that's a lot more readable IMHO.
Versus: honyarara.then(fugafugafuga, hogehogehoge, &p) And I am not sure the .call() is per se more readable. I agree about the trailing &p part; that one looks a bit weird. I guess it is just the block. But ignoring this, if it is merely between .call versus .then, then I think .then may be quite explicit and perhaps "more readable", whatever that means. So I am not sure that .call() is implicitely more readable than .then(). Although, I think one problem is that some ruby authors write code like: if condition then do_something end Or something like that. I never used that style, but some folks used that style in the past. So perhaps it's not quite so readable if we include the totality of the syntax out there. zverok wrote: 3.then.with_object(4).with_object(5).map { |(x, y), z| x + y + z }.first Is this still ruby though? :P ---------------------------------------- Feature #18690: Allow `Kernel#then` to take arguments https://bugs.ruby-lang.org/issues/18690#change-101913 * Author: sawa (Tsuyoshi Sawada) * Status: Open * Priority: Normal ---------------------------------------- `Kernel#then` passes the receiver to the block as its first positional block parameter. ```ruby 1.5.then{|x| Math.atan(x)} ``` I would like to propose to let `then` take arguments, which would be passed to the block as the other block parameters. ```ruby 3.then(4){|x, y| Math.hypot(x, y)} ``` There are two uses. First, to separate bulky or repeated parameters from the routine. Instead of writing: ```ruby honyarara.then{|x| foo(x) bar(fugafugafuga) baz(hogehogehoge) qux(x, fugafugafuga, hogehogehoge) } ``` we can then write: ```ruby honyarara.then(fugafugafuga, hogehogehoge){|x, y, z| foo(x) bar(y) baz(x) qux(x, y, z) } ``` Second, to use a proc with multiple parameters when, for some reason, you do not want to define a method to do it: ```ruby p = ->(x, y, z){ foo(x) bar(y) baz(x) qux(x, y, z) } honyarara.then(fugafugafuga, hogehogehoge, &p) ``` -- https://bugs.ruby-lang.org/