From: 7stud -- Date: 2009-04-30T16:28:06+09:00 Subject: Re: Defining a default proc for Hash Srijayanth Sridhar wrote: > Hello, > > Is there a way to redefine or newly define a default proc for Hash way > after > it has been constructed and populated with elements? > > There seems to be a #default= but no #default_proc= > Did you read this? ---------------------------------------------------------- Hash#default= hsh.default = obj => hsh ------------------------------------------------------------------------ .... It is not possible to set the a default to a +Proc+ that will be executed on each key lookup. ... # This doesn't do what you might hope... h.default = proc do |hash, key| hash[key] = key + key end h[2] #=> # h["cat"] #=> # -- Posted via http://www.ruby-forum.com/.