[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: efficient way to get the first found (or a random) key/value
From:       Emmanuel Touzery <emmanuel.touzery () wanadoo ! fr>
Date:       2004-01-14 12:11:52
Message-ID: 4005329A.6090003 () wanadoo ! fr
[Download RAW message or body]

Ville Aine wrote:

> David Garamond <lists@zara.6.isreserved.com> wrote in message \
> news:<40025921.4090603@zara.6.isreserved.com>... 
> 
> > # is there a #pairs method which returns [[k1,v1], [k2,v2], ...} or
> > # something similar?
> > 
> > 
> Hash#to_a does just that:
> 
> irb(main):003:0> {:a => 1, :b => 2}.to_a
> => [[:a, 1], [:b, 2]]
> 
> 
> 
yes, but converting the whole hash to an array is inefficient (for big 
hashes), that's why he doesn't want to use this.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic