From: Shannon Fang Date: 2002-12-03T18:19:27+09:00 Subject: Re: call-by-reference problem again I think it is explained already in the discussion. I am clear now, but I still think it is different. Because if you do this: a=b=c=d=e="hello" a="world" Then, b, c, d, e, won't be changed. Shannon >From: Mauricio Fern�ndez >Reply-To: ruby-talk@ruby-lang.org >To: ruby-talk@ruby-lang.org (ruby-talk ML) >Subject: Re: call-by-reference problem again >Date: Tue, 3 Dec 2002 17:31:00 +0900 > >On Tue, Dec 03, 2002 at 08:18:39AM +0900, Shannon Fang wrote: > > Hi, > > > > I modified my code, I'm afraid that I can't find it. It is like the > > following: > > > > class MailInfo > > def initialize > > @path=@recipients=@from=Array.new > > ... > > end > > def parse > > case header > > when "TO", "CC", "BCC" > > @recipients << header > > when "RECEIVED" > > @path << header > > end > > end > > ... > > end > > > > in the above code, the arrays will interfere with each other. The way to > > solve it is not to use chained assignment. > >Yes, because they are all the same array :) >But why is it any different from String(s)? > >-- > _ _ >| |__ __ _| |_ ___ _ __ ___ __ _ _ __ >| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ >| |_) | (_| | |_\__ \ | | | | | (_| | | | | >|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| > Running Debian GNU/Linux Sid (unstable) >batsman dot geo at yahoo dot com > >Linux - Das System fuer schlaue Maedchen ;) > -- banshee _________________________________________________________________ STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail