Hi -- On Mon, 8 Jan 2007, Trans wrote: > > Daniel Schierbeck wrote: > >> Is there really a need for such a method? Why not simply: >> >> hsh[:key] ||= "value" > > This isn't quite the same becasue it looks to see if tha value is nil > or false, not if the key is there or not. > >> or, if you have a default value on your hash: >> >> hsh[:key] = "value" unless hsh.has_key? :key > > Yes, certianly. nad that woul dbe fine if I were just needing here and > ther, but I have need for using it quite often. You can use merge and a one-key hash: hash.merge({ :key => "new value" }) David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)