From: macaco Date: 2008-02-05T11:14:28+09:00 Subject: Having problems with my instance variable ------=_Part_10138_3025138.1202177673173 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I'm sorry if this question seem stupid, but couldn't find it in the books. I have this code in the models directory: class Figure attr_reader :xpos, :ypos def initialize @xpos = 0 @ypos = 0 @other = 0 @another = 0 end def some call_other(@xpos,@ypos) end def more call_other(@other,@another) end def call_other(var1, var2) max = 9 var1= rand(max) var2=rand(max) end end And have this on my controller: def figure fig = Figure.new fig.some render :text => "

new values

"+fig.xpos.to_s+" "+fig.ypos.to_s end Problem is, it always print 0 0... as if the random wouldn't work, but I have test the random outside this method (calling it in the first method, not the second one), but the second method is one I need cos I use it too many times and with different instance variables Any help? ------=_Part_10138_3025138.1202177673173--