Hi --

On Tue, 12 Oct 2010, Scott Gonyea wrote:

> Because I love dead horses (or just low productivity). Two more code
> examples:
>
> # Just get a String, rawr
> var = begin
>        hash[key].to_s.downcase
>      rescue NoMethodError
>        ""
>      end

You should never get a NoMethodError on #to_s; it's defined on Object.
So you could write that as:

   var = hash[key].to_s.downcase

(though in the original post, var was supposed to be set to nil if
hash[key] was nil).


David

-- 
David A. Black, Senior Developer, Cyrus Innovation Inc.

   The                   Ruby training with Black/Brown/McAnally
   Compleat              Stay tuned for next event!
   Rubyist               http://www.compleatrubyist.com