From: ahoward Date: 2003-04-11T04:46:11+09:00 Subject: Re: changing behavior of literal {:k => :v} On Fri, 11 Apr 2003, Hal E. Fulton wrote: > ----- Original Message ----- > From: "ahoward" > Newsgroups: comp.lang.ruby > To: "ruby-talk ML" > Sent: Thursday, April 10, 2003 11:45 AM > Subject: changing behavior of literal {:k => :v} > > > > i would like to change the behavior of literal hashes > > > > eg do some bookeeping anytime a > > > > {:k => :v} > > > > is seen > > I once wanted to do this... the conclusion I > came to was that it is not possible. bummer. the pickaxe sort of implies it is : ... class methods [ ] Hash[ [ key => value ]* ] -> aHash Creates a new hash populated with the given objects. Equivalent to the literal { key, value, ... }. Keys and values occur in pairs, so there must be an even number of arguments. Hash["a", 100, "b", 200] � {"a"=>100, "b"=>200} Hash["a" => 100, "b" => 200] � {"a"=>100, "b"=>200} { "a" => 100, "b" => 200 } � {"a"=>100, "b"=>200} ... i'm referring to the last bit. -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ahoward@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================