From: Robert Klemme Date: 2006-08-15T03:35:14+09:00 Subject: Re: hash.keys and hash.values Erik Veenstra wrote: >> Here's another solution - maybe it's even more efficient as >> it doesn't need the transposing: > > Well, a quick benchmark... No, it isn't more efficient. Neither > time-wise, nor memory-wise. Your test doesn't prove higher memory usage for the inject version. The problem with the transpose approach is that you need an additional copy of the complete hash in mem which is not needed for inject. However, inject version is likely to cause more GC because of all the two element arrays created. You could retest this: keys, vals = [], [] hash.each {|k,v| keys << k; vals << v} This should be the most efficient approach - memory and performance wise. Kind regards robert