From: "Jan E." Date: 2012-10-02T07:19:34+09:00 Subject: Re: still learning by doing - connecting rooms in a game Sebastjan H. wrote in post #1078242: > How should I change these methods? I am not looking for the easy way > out by you just telling me;) but I am puzzled and stuck yet again. Why > does it get reset by just calling it? The method assigns a new array to @satchel. So each time you call it, the instance variable @satchel is overwritten. A solution (like I said) is to set the values in the initialize method. This will also allow you to define hp, rifle etc. through attr_reader. However, there may actually be situations where it makes sense to set default values on the fly isntead of ahead of time (like when the calculation is very expensive). In this case you'd do something like this: def my_getter @myvar ||= 123 end The assignment only happens when @myvar isn't nil (or false). So you avoid resetting the variable. Note that this doesn't work if nil or false can be actual values. In this case you'd need to use the "defined?" operator: def my_getter return @myvar if defined? @myvar @myvar = 123 end But in your case, simply use the initialize method. That's what it's for. -- Posted via http://www.ruby-forum.com/.