From: "T. Onoma" Date: 2003-12-07T20:14:01+09:00 Subject: Re: newbie question On Sunday 07 December 2003 10:41 am, nainar wrote: > In C, parameters are passed by value , unless pointers to variables are > used . > > In Perl, params are passed in the '@_' array and contains references to > the original variables and assignments to the elements of @_ are reflected > in the original vars(Execept when the whole '@_' is assigned to at once ). > > How does it work in Ruby?. I couldn't find anything on this in docs. I find it confusing sometimes myself too, but it does "pan out" when you think about how ruby works: ��def f2(b) � ��b[0]=[9,8,7] ���end In this case b references the passed variable like a c pointer, so assignment to one of its elements effects the original. �def f1(a) �� a=[9,8,7] ���end In this case you have "dettached" the original reference to a, giving it a new one, so the original is unaffected. Try this instead: �def f1(a) �� a.replace [9,8,7] ���end This all has to do with what = does --it assigns reference, and is not an inplace assignment. T.