From: ts Date: 2001-06-16T20:58:47+09:00 Subject: [ruby-talk:16535] Re: Confusion about alias and alias_method >>>>> "S" == Sean Russell writes: S> I don't quite understand this. S> :anysymbol.inspect # --> ":anysymbol" S> id = :anysymbol S> id.inspect # --> ":anysymbol" S> "inspect" is defined for Symbol, and it returns the same value as inspect S> called on a variable that holds a symbol (which is what happens in the Axe S> book, page 252). In page 252 of the book, id.inspect is used in an eval (i.e. in a string) and it do something like this (if :anysymbol.to_i == 9363) module_eval "alias_method :__9363__, :anysymbol" This is something perfectly valid. When you write id = :anysymbol alias_method :__9363__, id.inspect ruby first call #inspect, which return the human representation of id which is ":anysymbol" and then it search the method associated with this string, i.e. it search the method :anysymbol which is not defined. To have the equivalent with the example given in p 252 you must write something like this module_eval "alias_method :#__{id.to_i}__, id.inspect" Guy Decoux