RE: not understanding return statement

Andy Jones <[email protected]>
Newsgroups gmane.comp.lang.ruby.general
Message-ID <[email protected]>
>>>>>
To be fair, having @root (from class Foo) == foo.root, where "root" in class Foo does *not*, is somewhat counterintuitive.  I think it's a most excellent thing, but it does lead to confusion among those learning about attr_* useage.
<<<<<<

Honestly, it’s not really counterintuitive unless you expect a variable to magically become an attribute, and frankly if they did, that would be _more_ confusing.

Again: `root` is just a variable.  It’s private to the object.  `@root` is an attribute, which _can_ be public to the object.

If you have a basic understanding of what a class is and what an attribute is, then this is the easy bit.


Click here to view Company Information and Confidentiality Notice.<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer>

Please note that we have updated our privacy policy in line with new data protection regulations. Please refer to our website to view the ways in which we handle your data.


Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.