Mischa Fierer wrote:
> Hello,
> 
> I've been writing in ruby for a bit, but ran into something while
> working on a project that struck me as weird, and could not find a ready
> explanation.

Assigning a value to a parameter simply assigns a new variable to the 
letter, and adding something to a hash modifies the existing object, 
referenced by the variable. Similarily if you pass a string to a method 
def change(s) and inside the method do:
s="abc" # does not change the original object
s+="abc" # does not change the original object, because it is equivalent 
to s=s+"abc"
s<<"abc" # does change the outside object because it is an in-place 
modification
s.upcase! # does change
s=s.upcase # does not

Have a look: http://al2o3-cr.blogspot.com/2008/08/object-arr.html

TPR.
-- 
Posted via http://www.ruby-forum.com/.