Re: Array and Enum: Elements or Objects?

Hugh Sasse <[email protected]> Fri, 13 May 2011 18:24:23 +0100 (BST)
Newsgroups gmane.comp.lang.ruby.documentation
Message-ID <[email protected]>
On Fri, 13 May 2011, Gary Wright wrote:

> 
> On May 13, 2011, at 12:41 PM, Hugh Sasse wrote:
> >> 
> >> I also think it is completely appropriate to refer to 'nil' as an object.  Everything that has methods is an object in Ruby: nil, true, false, fixnum, symbols, etc.  I know that some people like to introduce a dichotomy between objects that can be referenced with syntactical sugar and those that can't but I think that just confuses things.
> > 
> > This paragraph would have been unnecessary if you had not trimmed my last
> > sentence! :-)  It does carry semantics of being nothing, so it is legitimate
> > to regard it as a non-object in cases where that applies such as uniq.  I
> > still had to use the term non-nil to make this distinction apparent, because
> > it is an object with a class and methods.
> 
> Sorry about the trimming.  I didn't mean to mis-represent your thoughts.  I was responding to:
> 
> >> Array#uniq where non-nil elements are
> >> objects.
> 
> Uniq doesn't treat nil differently than any other object so I wasn't sure why you were suggesting that nil wasn't an object in this context.

Yes.  It really didn't help that I was thinking about the effects of
Array#compact, thinking they applied to uniq. Sorry about that. I
proved myself wrong, you right, with IRB in 30 seconds.  I've just
searched through the array docs, and have not found anything that
could have caused me to think this, so I don't know where that came
from.  Oh well. "Open mouth, insert foot, echo internationally" as
the old FIDOnet .sig used to go.

> 
> I think things are clearer when people realize that 'nil' is simply one particular object that has an agreed upon name.  it is a sigil or sentinel that can be used for a wide variety of purposes.  Its value is that it will never be confused with other objects and that it evaluates to false in a boolean context.   I think it goes too far to describe it as representing 'nothing' though.  

OK, that is more precise.  

I think I've just proved that I am not sufficiently accurate in my thinking
to comment on this activity, so I'll say no more.
> 
> Gary Wright
> 
        Hugh