From: Brian Xue Date: 2011-05-17T11:24:31+09:00 Subject: Re: where does the pure method defined when starting irb --0015174c4278b263db04a36f772c Content-Type: text/plain; charset=ISO-8859-1 Thank you very much, Michael! Brian On Tue, May 17, 2011 at 9:00 AM, Michael Edgar wrote: > An instance variable doesn't get created until it is first assigned. So in > this case, you > have to call `hello` before @v will show up in `self.instance_variables`: > > puts self > => main > def hello > @v = 1 > end > => nil > puts self.instance_variables > => nil > hello > => 1 > puts self.instance_variables > => @v > => [:@v] > > Michael Edgar > adgar@carboni.ca > http://carboni.ca/ > > On May 16, 2011, at 8:54 PM, Brian Xue wrote: > > > Can anyone help explain? > > > > Many thanks! > > > > Brian > > > --0015174c4278b263db04a36f772c--