From: Jim Moy Date: 2003-12-13T07:05:58+09:00 Subject: [Nuby] Object ID Lookup? Hi all, a Ruby Nuby here with a question. Is there a way to lookup an object reference from the object's id? Something to do like the following, but without the need for the lookup hash: a = { "a" => 1, "b" => 2 } b = { "c" => 4, "d" => 3 } arr = [a, b] ids = arr.collect {|h| h.id} lookup = {} arr.each { |h| lookup[h.id] = h } cmp = ids.collect {|id| lookup[id]} ids == cmp => true In my instance, I've got a reference set of hashes that I'm pointing to from multiple arrays. Those arrays are manipulated depending on sorting and other factors. I don't want to get Hash#== involved so I'm using the Hash object id's. After processing is completed, I'd like to get back from the IDs to the object references. The lookup is working, but I was wondering if there was a better method. Thanks for any suggestions, Jim Moy Fort Collins, Colorado USA