From: Stu Date: 2011-02-05T14:15:58+09:00 Subject: Re: variables and scope take note of the usage of @ for scope as well as the special initialize method used as a constructor for the object. also note note you common bug/mistake. Your where setting n to negative one. you need to use n = n + -1 or shorthand version below is n += -1 class Test def initialize @n = 100 end def pt p "hi there" @n += -1 end end t = Test.new puts t.pt If you would like to know more have a look at attr_* in ruby Good luck with your classes ~Stu On Fri, Feb 4, 2011 at 10:17 PM, Mike 1. wrote: > Hi all, > >  I would be asking my instructor this question be she is not available > on > the weekends... > >  How do I make "n" available from anywhere inside the class? I need to > keep the values in n from call to call. > >  When calling the method "pt", "n" acts as if it was not declared above. > >  I get -1 instead of what I wish for ... 99. > >  Thanks in advance, > >  Mike > > class Test > n=100 > >  def pt >   puts "hi there" >   n=-1 >  end > > end > > t = Test.new > puts t.pt > > -- > Posted via http://www.ruby-forum.com/. > >