From: "David A. Black" Date: 2008-10-28T20:41:27+09:00 Subject: Re: Hash.merge_add! extension - how does this code look? Hi -- On Tue, 28 Oct 2008, Greg Hauptmann wrote: > interesting - is it really Ruby approach to let things 'break' during > a method so to speak as opposed to defensive coding and doing some > form of validation at the beginning of the method? I noted when I run > my spec's with your code i get the error > > "" > > which is quite a bit more cryptic than my > > "RuntimeError - "Parameter passed in not a hash" > > Wouldn't it be harder to debug code if one were getting the former > error message rather than the later? Not really. The first message actually gives you more information about what happened, which is likely to help you pinpoint it better. You'll see a fair amount of class-checking in the Ruby source code, but mostly in the C code, which after all is a C program and not a Ruby program, and which has the job of bootstrapping the actual Ruby environment into being. In Ruby itself, it's relatively unusual to check class membership directly (or at least it's unusual to have any compelling reason to). David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL Advancing with Rails January 19-22 Fort Lauderdale, FL * * Co-taught with Patrick Ewing! See http://www.rubypal.com for details and updates!