Add more accessors in child class : child class « Class « Ruby






Add more accessors in child class


class Pet
  attr_accessor :name, :age, :gender, :color
end

class Cat < Pet
end

class Dog < Pet
end

class Snake < Pet
  attr_accessor :length
end

 








Related examples in the same category

1.Add method to child class
2.Check class attribute of child class
3.Add methods in subclass