Ruby では、そのクラスのインスタンスの 1 つからクラス メソッドをどのように呼び出すのでしょうか? 私が持っていると言う
class Truck
def self.default_make
# Class method.
"mac"
end
def initialize
# Instance method.
Truck.default_make # gets the default via the class's method.
# But: I wish to avoid mentioning Truck. Seems I'm repeating myself.
end
end
行Truck.default_make
はデフォルトを取得します。しかし、言及せずにこれを言う方法はありTruck
ますか? あるべきだと思われます。