class Truck < Vehicle
def initialize @wheels = 16
I am curious which way is considered correct or better to invoke
wheels writer method of mother Vehicle?
Truck#initialize does not invoke any writer method at all but plain
assigns an instance variable @wheels. If you have a writer method
then it is generally considered much more robust to use it (like you
did in Car#initialize) because the writer might do more than to just
assign to a local variable (e.g. validity checks which ensure the
value is an integer value and greater or equal to 0).
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.