From: Walton Hoops Date: 2010-02-04T12:53:49+09:00 Subject: Re: hooking subscript operations in a hash On 2/3/2010 8:11 PM, Ralph Shnelvar wrote: > Is there any way to do it for all hash subscript operations? > irb(main):012:0> class Hash irb(main):013:1> alias_method :old, :[]= irb(main):014:1> def []=(index, value) irb(main):015:2> p index irb(main):016:2> p value irb(main):017:2> old index, value irb(main):018:2> end irb(main):019:1> end => nil irb(main):020:0> x={} => {} irb(main):021:0> x[:foo]=:bar :foo :bar => :bar irb(main):022:0> That should get you where your trying to go. Best of luck!