From: Xavier Noria Date: 2007-01-28T04:41:03+09:00 Subject: Re: pass by reference? On Jan 27, 2007, at 8:25 PM, Thomas Hafner wrote: > That's another story. With the code above you rather reset b to a new > object instead of modifying the passed object. Look here: > > def m(b) > b.shift > b.unshift(7) > end > a = [3] > m(a) > => [7] > > Would that be the same with pass-by-value? No, I don't think so. Yes, that's the usual point in the discussion. Being able to change the internal state of mutable objects is not a test for pass-by- reference. Java is pass-by-value for instance (according to the JLS) and that test passes. Problem with the assignment-seen-in-the-caller test is what dblack pointed out, it mixes assigment semantics. In Perl, which is pass by reference, you can do this for example: $ perl -wle '$x = 0; sub { ++$_[0] }->($x); print $x' 1 -- fxn