From: gwtmp01@... Date: 2005-10-19T04:52:45+09:00 Subject: Re: The Ruby Way to build an object unless nil? On Oct 18, 2005, at 2:42 PM, Kevin Ballard wrote: > I'm not sure what the ideal is, but this is certainly more terse: > def mymethod > a = someobjectreference('a') > b = a.some_attribute unless a.nil? > c = b.some_attribute unless b.nil? > c.dosomething unless c.nil? > end How about: module Kernel def send_each(*mlist) mlist.inject(self) do |obj, mname| return nil unless obj obj.send(mname) end end end puts "ruby rocks".send_each(:reverse, :chop, :capitalize) # -> "Skcor ybu" Gary Wright