From: Corey Konrad <0011@...> Date: 2007-03-18T01:23:10+09:00 Subject: Re: attr_accessor question > > c=C.new #now, C#initialize is called > c.instance_variables > => ["@var"] #now, @var exists > c.greater? 3 > => false > c.greater? -1 > => true > > By the way, if you define an initialize method for a class which doesn't > derive directly from Object, you'll usually want to call the parent > class's > initialize from your own, otherwise the parent class's instance > variables > won't be initialized: > > class A > def initialize #We don't need to call Object#initialize: it does > nothing > @var=0 > end > end > > class B < A > def initialize > super #We call the parent class's initialize; otherwise, @var won't be > set > @var1=1 > end > end > > I hope this helps > > Stefano So i have to use the age accessor in an initialize method? i dont understand what the difference is between the age accessor in that example program and any of the others why would the age variable need to be set before i used it and what does that have to do with the error message i received telling me to parenthesize for future versions? thanks -- Posted via http://www.ruby-forum.com/.