From: Wai-Sun Chia Date: 2002-12-29T15:59:17+09:00 Subject: Re: Hash question Does this work? self.backColor = @options["GUI"]["backColor"] ||= FXColor::Red warning: this is off my head, and not tried... Kurt V. Hindenburg wrote: > I'm using FXRuby and YAML, but this question deals with using a hash : > > Is there a better/easier way to do this? > > self.backColor = @options["GUI"].has_key?("backColor") ? > @options["GUI"]["backColor"] : FXColor::Red > > Basically, if backColor is a key then use that key's value else use the > default. > > I'm going to have a lot of these...I wonder if there is a better way to handle > this... > -- Wai-Sun "Squidster" Chia Consulting & Integration Linux/Unix/Web Developer Dude "Just Another Ruby Miner"