------art_169680_9735783.1169283274559
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On 1/20/07, CBlair1986 <CBlair1986 / gmail.com> wrote:
>
> <snip>
>
>   def update_timer
>     timer  ime.now


you are assigning to a local variable, as you found out  yourself you can
assign to the instance variable
       @timer  ime.now
if you want to use the accessor method you have to write this as
       self.timer  ime.now

  end
> end
>
> But, as simple as it looks, it doesn't work. I'll make a new Test
> object and call update_timer all I want, and it won't update. It seems
> a bit counter-intuitive. I've made an accessor for a variable that I
> declare when initialized, and then go to change it, and it doesn't
> work.
>
> However, if I change the 'timer' in update_timer to '@timer', it works
> perfectly fine. Why is this?


This is a trap lots of folks falls in, Ruby just prefers autocreation of
local variables
to method resolution.

HTH
Robert

Thank you!
>
>
>


-- 
"The best way to predict the future is to invent it."
- Alan Kay

------art_169680_9735783.1169283274559--