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 batsman.geo@yahoo.com
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 +0900On 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
…
endin 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 comLinux - 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