R
Richard Leber
I am stumbling around some of the nuances of Ruby classes, especially in
regard to alias_method. Specifically, can someone explain to me why this
doesn't work:
class A
def A.foo
"Hello"
end
end
A.sendalias_method, :bar, :foo) # => NameError: undefined method
`foo' for class `A'
But this does:
class A
def A.foo
"Hello"
end
end
class << A
alias_method :bar, :foo
end
A.foo # => Hello
A.bar # => Hello
regard to alias_method. Specifically, can someone explain to me why this
doesn't work:
class A
def A.foo
"Hello"
end
end
A.sendalias_method, :bar, :foo) # => NameError: undefined method
`foo' for class `A'
But this does:
class A
def A.foo
"Hello"
end
end
class << A
alias_method :bar, :foo
end
A.foo # => Hello
A.bar # => Hello