From: dagbrown@... (Dave Brown) Date: 2003-12-06T02:52:03+09:00 Subject: Re: Dumb question to which I ought to know the answer by now In article <20031205141744.GA18597@mulan.thereeds.org>, Mark J. Reed wrote: : On Fri, Dec 05, 2003 at 11:03:07PM +0900, Austin Ziegler wrote: : > What you can do is: : > : > hash = nil; keys.zip(value) { |k, v| (hash ||= {})[k] = v } : : Now that is handy. I assume there's a historical reason for the : name 'zip'? Because I would never have thought it meant : "iterate in parallel with". :) That's not quite what zip does. The reason it's called "zip" is that it's stolen directly from Python, which has a function by that name which does just that. It takes corresponding elements from two arrays and groups them together: irb(main):001:0> [1,2,3,4].zip([5,6,7,8]) => [[1, 5], [2, 6], [3, 7], [4, 8]] Another thing you could use would be "transpose", which is a more-general method to do similar things: irb(main):002:0> [[1,2,3,4],[5,6,7,8]].transpose => [[1, 5], [2, 6], [3, 7], [4, 8]] --Dave