On Sep 9, 2006, at 10:37 AM, Marshall T. Vandegrift wrote:

> ara.t.howard / noaa.gov writes:
>
>> tr{ tr @item.foo } unless @item.foo.to_s.empty?
>
> It makes sense to me that
>
>     object.to_s.empty? # => true
>
> should imply
>
>     object.empty? # => true
>
Doesn't to me. nil is not a container, and it should not be treated  
as one. A string is a container (contains a sequence of characters)  
and can therefore be empty. The fact that one, arbitrary string  
representation of nil happens to be the empty string doesn't mean  
that nil is empty. (This is also why I disklike rails's #blank?, but  
at least it's named something different.)

> So why not just do
>
>     class NilClass
>       def empty?; true; end
>     end
>
> ?
>
> -Marshall
>
>