From: Gavin Sinclair Date: 2002-12-29T18:49:19+09:00 Subject: Re: Hash question On Sunday, December 29, 2002, 5:53:11 PM, Kurt wrote: > I'm using FXRuby and YAML, but this question deals with using a hash : > Basically, if backColor is a key then use that key's value else use the > default. value = hash[key] || default The other response recommended value = hash[key] ||= default Be warned, that modifies the hash, which is not what you asked. Since you have a lot of keys and defaults, a nice approach is to put all the default values into a separate hash, then do something like this: final_hash = given_hash.dup.update(defaults_hash) Cheers, Gavin