From: "David A. Black" Date: 2005-03-11T00:58:17+09:00 Subject: Re: Is iterating in lock-step possible? --927295978-1099658342-1110470283=:21715 Content-Type: MULTIPART/MIXED; BOUNDARY="927295978-1099658342-1110470283=:21715" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --927295978-1099658342-1110470283=:21715 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Thu, 10 Mar 2005, [ISO-8859-1] Brian Schr=F6der wrote: > On Thu, 10 Mar 2005 22:06:10 +0900, ts wrote: >>>>>>> "B" =3D=3D =3D?ISO-8859-1?Q?Brian Schr=3DF6der?=3D wri= tes: >> >> B> Or in simple cases where the additional memory overhead is not >> B> important, you can also use the zip funtion. I.e. >> >> B> %w(eins zwei drei).zip([1,2,3]).each do | name, value | >> B> puts "The value of #{name} is #{value}" >> B> end >> >> Why do you use #each ? >> >> svg% ruby -e '%w(eins zwei drei).zip([1,2,3]) {|a, b| puts "#{a} #{b}" }= ' >> eins 1 >> zwei 2 >> drei 3 >> svg% >> >> no memory overhead >> >> Guy Decoux >> >> > > Thank you, I thought that was something not yet in the standard lib. > Wasn't there a discussion about this on this list not so long ago? I think you might be thinking of discussion of the return value for #zip when a block is used -- that is, whether it should return the zipped array (as it does when there's no block) instead of nil. David --=20 David A. Black dblack@wobblini.net --927295978-1099658342-1110470283=:21715-- --927295978-1099658342-1110470283=:21715--