Project

General

Profile

Actions

Bug #7613

closed

An Alias for a class method inherited from the Class class is not equal to the original method

Added by zhangsu (Su Zhang) almost 12 years ago. Updated almost 12 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.3p327 (2012-11-10) [i386-mingw32]
Backport:
[ruby-core:51105]

Description

class Stream
  class << self
    alias_method :open, :new
  end
end

open = Stream.method(:open)
new = Stream.method(:new)
p open, new                   # => #<Method: Stream.new>, #<Method: Class#new>
p open.receiver, new.receiver # => Stream, Stream
p open == new                 # => false

Expect the last line to return true, but got false. According to the documentation for Method#==:

Two method objects are equal if they are bound to the same object and refer to the same method definition.

Here, open and new are all bound to Stream and I expect them to refer to the method definition too.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0