What symbol for class methods?

Hello,
some methods require as an argument a symbol of a method (e.g.
alias_method). How can one use it with class methods?

Thanks.

Diego

Diego V. wrote:

Hello,
some methods require as an argument a symbol of a method (e.g.
alias_method). How can one use it with class methods?

Thanks.

Diego

class A
def A.show(symbol)
puts “%s <–> %s” % [symbol.inspect, symbol.to_s]
end
end

A.show(:hello)

–output:–
:hello <–> hello

Diego V. wrote:

Hello,
some methods require as an argument a symbol of a method (e.g.
alias_method). How can one use it with class methods?

Hmm…what does ‘it’ refer to? Does ‘it’ refers to alias_method?

As far as I can tell, you can’t use alias_method with symbols like:

:self.meth_name

for arguments. However, this seems to work:

class A
def self.greet
puts “hello”
end

class<<self
alias_method :old_greet, :greet
end

end

A.old_greet #hello