0
問題在於標題。說我有下面一個簡單的例子:初始化調用其母親的實例方法的對象的正確方法是什麼?
class Vehicle
attr_accessor :wheels
end
class Car < Vehicle
def initialize
self.wheels = 4
end
end
class Truck < Vehicle
def initialize
@wheels = 16
end
end
我很好奇它的方法是正確的或更好的調用 母親Vehicle
的wheels
作家方法?