On Sunday 07 December 2003 12:43, nainar wrote: > If function are params are only copies , why do the two functions below > behave differently: > > def f1(a) > a=[9,8,7] > end Because in this case, not object that 'a' refers to is changed, but variable 'a' itself assigned to a new object [9,8,7]. > def f2(b) > b[0]=[9,8,7] > end But now, object that 'b' refers to is changed, not variable 'b'. > v=[1,2,3] > f1(v) > p v # prints [1,2,3] : 'v' not changed When variable assigned to a new object, old object still exists. And v holds reference to it, no matter what f1 did. > f2(v) > p v # prints [[9,8,7],2,3] ! -- sdmitry -=- Dmitry V. Sabanin MuraveyLabs.