From: Ken Bloom Date: 2006-09-10T11:45:08+09:00 Subject: Re: Combine @item.foo.nil? || @item.foo.empty? ? On Sat, 09 Sep 2006 06:53:59 +0900, Joel VanderWerf wrote: > Matthew Moss wrote: >>> tr do >>> td @item.foo >>> end unless (@item.foo.nil? || @item.foo.empty?) >>> >>> Is there a way to combine these two OR clauses into one? >> >> >> Define a method on the class of foo? >> >> class Foo > ^^^ > Object >> def nil_or_empty? >> return nil? || empty? >> end >> end > > Otherwise it won't be defined when foo==nil. > So define as follows: class NilClass def nil_or_empty? true end end -- Ken Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/