Li Chen wrote:
> I expect that once an array is set up it should be fixed regardless how
> many times it is called.

I'm not sure why you expect that.

In your program, you first assign @b1 to an empty array.

In method2, you loop around 4 times pushing '10' onto the end of the 
array. Therefore @b1 becomes, each time around the loop,
[10]
[10,10]
[10,10,10]
[10,10,10,10]

If you call method2 again, then again 4 times you push 10 onto the end 
of the array, so after that you get
[10,10,10,10,10,10,10,10]

Why would you expect the first four pushes to work, but the second 4 
pushes not to work?
-- 
Posted via http://www.ruby-forum.com/.