Need help to understand the Method#original_name

The documentation of
Method#original_name(http://www.ruby-doc.org/core-2.0/Method.html#method-i-original_name)
I today read. Accordingly I tried the below example:

class Foo
  def bar;end
end
foo = Foo.new
foo.method(:bar).original_name
# ~> -:5:in `<main>': undefined method `original_name' for #<Method:
Foo#bar> (NoMethodError)

But I am not getting,why the error comes out?

···

--
Posted via http://www.ruby-forum.com/.

the Changelog says:

···

Wed Feb 13 18:11:59 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>

  * proc.c (method_original_name): new methods Method#original_name and
    UnboundMethod#original_name. [ruby-core:52048] [Bug #7806]
    [EXPERIMENTAL]

  * proc.c (method_inspect): show the given name primarily, and
    original_id if aliased. [ruby-core:52048] [Bug #7806]

maybe your ruby is older than this?

#original_name is for difference an aliased method with an normal method

class A
def abc
end
alias xyz abc
end

A.instance_method(:abc) #=> #<UnboundMethod: A#abc>
A.instance_method(:xyz) #=> #<UnboundMethod: A#xyz(abc)>

--
Posted via http://www.ruby-forum.com/.

I'd say since there's the tag [EXPERIMENTAL] in that description, it's
something which isn't supposed to be used yet.
You can see the original name of a method when you inspect it anyway, so
there's no need for original_name, or you could write your own by
parsing the inspection string.

···

--
Posted via http://www.ruby-forum.com/.

Hans Mackowiak wrote in post #1119150:

maybe your ruby is older than this?

@Hans I am using Ruby2.0.0-p0 in my Ubuntu13.04 system. It is very new
Ruby version..but why I am getting such issue? :frowning:

···

#original_name is for difference an aliased method with an normal method

class A
def abc
end
alias xyz abc
end

A.instance_method(:abc) #=> #<UnboundMethod: A#abc>
A.instance_method(:xyz) #=> #<UnboundMethod: A#xyz(abc)>

--
Posted via http://www.ruby-forum.com/\.