Re: Array and Enum: Elements or Objects?
Gary Wright <[email protected]> Fri, 13 May 2011 12:49:22 -0400
| Newsgroups | gmane.comp.lang.ruby.documentation |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail-7-580647889 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On May 13, 2011, at 12:41 PM, Hugh Sasse wrote: >>=20 >> 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. >=20 > 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. 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. =20 Gary Wright --Apple-Mail-7-580647889 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii <html><head></head><body style=3D"word-wrap: break-word; = -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; = "><br><div><div>On May 13, 2011, at 12:41 PM, Hugh Sasse = wrote:</div><blockquote type=3D"cite"><div><blockquote type=3D"cite"><font= class=3D"Apple-style-span" = color=3D"#000000"><br></font></blockquote><blockquote type=3D"cite">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.<br></blockquote><br>This paragraph would have been unnecessary = if you had not trimmed my last<br>sentence! :-) It does carry = semantics of being nothing, so it is legitimate<br>to regard it as a = non-object in cases where that applies such as uniq. I<br>still = had to use the term non-nil to make this distinction apparent, = because<br>it is an object with a class and methods.<font = class=3D"Apple-style-span" = color=3D"#006312"><br></font></div></blockquote><br></div><div>Sorry = about the trimming. I didn't mean to mis-represent your thoughts. = I was responding to:</div><div><br></div><div><blockquote = type=3D"cite" style=3D"font-family: monospace; "><blockquote = type=3D"cite">Array#uniq where non-nil elements = are<br></blockquote></blockquote><blockquote type=3D"cite" = style=3D"font-family: monospace; "><blockquote = type=3D"cite">objects.</blockquote></blockquote><br></div><div>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.</div><div><br></div><div>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. </div><div><br></div><div>Gary = Wright</div><br></body></html>= --Apple-Mail-7-580647889--