On Thursday 24 July 2008, Sijo Kg wrote:
Thanks in advance
.nil? tests whether the receiver is the nil object, that is the only
of class NilClass, which is often used to indicate an invalid value.
method is defined in class Object, and thus is availlable for every
The other two methods, instead, are defined only for specific classes,
answer depends. Usually, empty? is used to test whether an object is
for some class-depending meaning of empty. For example, String#empty?
true if the string contains no characters, Array#empty? and Hash#empty?
returns true if the array or hash has no entries. Other classes may
empty? method in other ways. Note that, unlike nil?, empty? isn’t
Regarding blank?, I never heard of it, so I can’t help you. You should
the documentation of the class defining it.
Here are some examples about nil? and empty?
[1, 2, 3].empty?
The last example means that the empty? method is not defined for class
I hope this helps