特異クラスでaliasを使うと、クラスメソッドの別名を定義することができます。
class Foo
class << self
def bar
return 'bar'
end
alias foo bar
end
end
Foo.bar #=> 'bar'
Foo.foo #=> 'foo'
特異クラスでaliasを使うと、クラスメソッドの別名を定義することができます。
class Foo
class << self
def bar
return 'bar'
end
alias foo bar
end
end
Foo.bar #=> 'bar'
Foo.foo #=> 'foo'
突然失礼します。
Foo.foo #=> ‘bar’ ではないでしょうか??