M
Mark Volkmann
If Struct is a shorthand way for creating Classes, why don't objects
created from those Classes have instance_variables?
Struct.new 'Car', :make, :model, :year
c =3D Struct::Car.new 'Saturn', 'SC2', 1997
c.instance_variables =3D> []
c.members =3D> ["make", "model", "year"]
Note that members is an instance method of Struct, whereas
instance_variables is an instance method of Object.
created from those Classes have instance_variables?
Struct.new 'Car', :make, :model, :year
c =3D Struct::Car.new 'Saturn', 'SC2', 1997
c.instance_variables =3D> []
c.members =3D> ["make", "model", "year"]
Note that members is an instance method of Struct, whereas
instance_variables is an instance method of Object.