Method
A Ruby Method object represents a method that is attached (the technical term is “bound”) to a specific receiver. You create Method objects via Object#method(name), which returns the method object for a given name.
Once you have a method object, you can call the method with call(*, **, &), which forwards the arguments to the method and invokes it with the method object’s receiver. The call method is aliased as [] and also as ===.
You can compose Ruby methods in a functional programming style with Method#<<(other_proc), which takes a proc or callable object as the right-hand side and returns a new proc. The new proc takes arguments, calls other_proc, and then calls the given method with the result of the call to other_proc. The flip ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access