Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

UnboundMethod#==

(untyped other) -> bool
meth == other_meth → true or false

Two unbound method objects are equal if they refer to the same method definition.

Example
Array.instance_method(:each_slice) == Enumerable.instance_method(:each_slice)
#=> true

Array.instance_method(:sum) == Enumerable.instance_method(:sum)
#=> false, Array redefines the method for efficiency

Ruby version changes

  1. 3.2
    • UnboundMethod#== returns true if the actual method is same. For example, String.instance_method(:object_id) == Array.instance_method(:object_id) returns true. [Feature #18798]

See also #arity #bind also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0