From: Bill Walton Date: 2008-07-25T02:14:25+09:00 Subject: Re: differnce between .nil? , .empty?, .blank? Hi Marc, Marc Heiler wrote: > Isn't .nil? and .empty? in a way testing for a very similar > situation? Not in Ruby. empty? is true for a String of length 0. The value of the String is not Nil. It turns out that Nil is very important in evaluations since it's one of the two items in Ruby that evaluates to false. irb(main):001:0> str = String.new => "" irb(main):002:0> str.length => 0 irb(main):003:0> if str then puts 'a zero-length string is still a string' end a zero-length string is still a string => nil irb(main):004:0> str = nil => nil irb(main):005:0> if str.nil? then puts 'assigning a nil value essentially kills the object' end assigning a nil value essentially kills the object => nil. HTH, Bill