Hi --

On Sat, 23 Jul 2005, Daniel Brockman wrote:

> Hi Mark,
>
>> I was wondering if there were a module that supplied [...]
>> a self-modifying method that works like update() but
>> without clobbering existing values.
>
> Here's what I use, FWIW:
>
>   def compensate(defaults)
>     defaults.merge self
>   end

I'm curious what this gains you.  Is it better than just saying
defaults.merge(self)?

>   def compensate!(defaults)
>     for key, value in defaults do
>       self[key] = value unless include? key
>     end
>   end

That one seems to do more :-)


David

-- 
David A. Black
dblack / wobblini.net