From: Alan Chen Date: 2002-09-27T07:55:13+09:00 Subject: Re: hash missing value On Fri, Sep 27, 2002 at 07:37:56AM +0900, William Djaja Tjokroaminata wrote: > Hi, > > I think it is already there. If you first declare the hash with > > files = Hash.new ("Untitled") > > then you will get "Untitled" instead of nil for any missing key. (But of > course, then you cannot create and populate the hash at the same time :) > > Regards, > > Bill > ============================================================================ > MikkelFJ wrote: > > Wouldn't it be useful with a missing value in hash tables so you avoid > the > > nil value and having to test for this? > You can set it after initialization too > > files = { "item1" => "myfile.rb", "item2" => "mytestdata", missing_value => > > "Untitled"} files.default = "Unititled" > > window.caption = files[current_item] -- Alan Chen Digikata LLC http://digikata.com