End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Method#<<
meth << g → a_proc
proc.c
View on GitHub ↗
static VALUE
rb_method_compose_to_left(VALUE self, VALUE g)
{
g = to_callable(g);
self = method_to_proc(self);
return proc_compose_to_left(self, g);
}
Returns a proc that is the composition of this method and the given g. The returned proc takes a variable number of arguments, calls g with them then calls this method with the result.
Example
def f(x) x * x end f = self.method(:f) g = proc {|x| x + x } p (f << g).call(2) #=> 16