From: Daniel Sheppard Date: 2005-12-01T09:37:31+09:00 Subject: Re: Point an element in Hash Object I thought something like this was in facets... maybe it was one of those other library collections... either way I can't find what I'm looking for, so here's an implementation which probably screws up with some corner cases. class Reference instance_methods.each { |m| undef_method m unless /__.*__/ === m} def initialize(&block) @block = block end def method_missing(*args, &block) @block.call.send(*args, &block) end end my_hash = {} my_hash["one"] = "First" my_hash["two"] = "Second" my_hash["three"] = "Third" my_hash["four"] = Reference.new{my_hash["one"]} my_hash["five"] = Reference.new{my_hash["four"]} my_hash["one"] = "Modify" p my_hash["four"] => "Modify" p my_hash["five"] => "Modify" > -----Original Message----- > From: list-bounce@example.com > [mailto:list-bounce@example.com] On Behalf Of Andrew > Sent: Thursday, 1 December 2005 9:06 AM > To: ruby-talk ML > Subject: Point an element in Hash Object > > I'm trying to create an hash object using object string for > key and value. > I need to link a key with another key as value... so an > element of hash object can point to another element. But i > need the link to the key and not a copy of the value. ##################################################################################### This email has been scanned by MailMarshal, an email content filter. #####################################################################################