From: Avdi Grimm Date: 2007-03-22T00:48:33+09:00 Subject: Re: nil? with block ------=_Part_148234_9061799.1174492108623 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 3/21/07, Michiel de Mare wrote: > > user.personal_data.address.nil?{ raise 'no address!'}.zipcode > > Instead of interrupting the main flow of code with error handling, how about this: begin zipcode = user.personal_data.address.zipcode rescue NoMethodError => error case error when :personal_data then raise "No user!" when :address then raise "No personal data!" when :zipcode then raise "No address!" end In fact, thanks for spurring me to think of that technique, I think I'm going to use it in future! -- Avdi ------=_Part_148234_9061799.1174492108623--