Instance Variables Inheritance

前端 未结 4 726
孤城傲影
孤城傲影 2021-02-12 17:08

Can someone explain how a class can access the instance variables of its superclass and how that is not inheritance? I\'m talking about \'The Ruby Programming Language\' and the

4条回答
  •  一整个雨季
    2021-02-12 17:33

    super(x,y) calls the constructor of the base class, which is the initialize method. If you take super(x,y) out, then the variables @x and @y won't appear in the derived class.

提交回复
热议问题