From: William Djaja Tjokroaminata Date: 2002-09-27T08:38:20+09:00 Subject: Re: hash missing value Hi, I think this has been discussed before. We can take an advantage of, as one instructor put it, "the short circuit concept from electrical engineering", i.e., A || B # if A is false, then B should be evaluated; otherwise B is not and a similar concept for &&. So you can simply write: window.caption = files[current_item] || "Untitled" Regards, Bill ============================================================================ MikkelFJ wrote: > As an extension or alternative to this, what about a two value assigment > where the second value is assigned if the first value is false or nil: > files = { "item1" => "myfile.rb", "item2" => "mytestdata"} > window.caption = files[current_item] alternative "Untitled" > or > window.caption = files[current_item] \/ "Untitled" > Mikkel