From: "Mauricio Fernández" Date: 2003-07-06T03:23:47+09:00 Subject: Re: Is this a bug? On Sun, Jul 06, 2003 at 02:46:28AM +0900, Aryeh Friedman wrote: > Is this a bug in ruby? No, it's the normal assignment semantics: >> a = 1, 2, 3 => [1, 2, 3] >> a => [1, 2, 3] > class Foo > def intialize(aVal,bVal) > @aVal=aVal > @bVal=bVal > end > > def ack > yield(@aVal,@bVal) > end > end > > foo[0]=Foo.new("ack","ack") > foo[1]=Foo.new("bar","bar") > foo[2]=Foo.new("foo","foo") > > foo.each { |aVal| puts aVal } Use foo.each { |aVal,| puts aVal } See the difference: >> [[1,2],[3,4]].each { |v,| p v } 1 3 => [[1, 2], [3, 4]] >> [[1,2],[3,4]].each { |v| p v } [1, 2] [3, 4] > Produces: > > ack > ack > bar > bar > foo > foo > > It seems the output should be: > > ack > bar > foo -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com The first is to ensure your partner understands that nature has root privileges - nature doesn't have to make sense. -- Telsa Gwynne