From: Daniel Lucraft Date: 2007-03-21T22:53:02+09:00 Subject: Re: nil? with block Michiel De mare wrote: > If "nil?" is extended to accept a block, and to return self (for > Object) and the result of the yield (for NilClass), the following > notation becomes possible: > > user.personal_data.address.nil?{ raise 'no address!'}.zipcode > Why not use Object#tap? user.p_data.address.tap {|a| raise "no address!" unless a}.zipcode It's included in Ruby 1.9, is easily definable otherwise (http://rubyurl.com/eG5) and does basically what you want. best, Dan -- Posted via http://www.ruby-forum.com/.