[Rails] [ANN] "Ruby for Rails" now available in PDF!

Ken Kousen
Tue, 18 Apr 2006 13:35:38 -0000

Of course, that''s another trap.  In Java, the words "instance
variables" and
"attributes" are interchangeable. :)

Ken

--
Kenneth A. Kousen, Ph.D.
President
Kousen IT, Inc.
http://www.kousenit.com
ken.kousen@kousenit.com
-----Original Message-----
From: rails-bounces@lists.rubyonrails.org
[mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of
dblack@wobblini.net
Sent: Monday, April 17, 2006 11:30 PM
To: rails@lists.rubyonrails.org
Subject: RE: [Rails] [ANN] "Ruby for Rails" now available in PDF!

Hi --

On Mon, 17 Apr 2006, Ken Kousen wrote:

> 3. If you declare an attribute outside a method (the way you normally do
in
> Java), you''re actually creating an attribute of the _class_ (i.e.,
a
static
> attribute) rather than of an instance attribute.  You need to create
> instance attributes inside a method.  Outside a method, "self" is
the
Class
> (!).

I think you mean instance variables here, rather than attributes.
Attributes are kind of second-order constructs layered on top of
instance variables (i.e., when you do attr_reader and related methods,
the attribute methods Ruby generates are implemented using instance
variables).  But the instance variables themselves are not attributes;
they can be used for different purposes.

Maybe this makes it less of a ''gotcha'', in the sense that
instance
variables can be understood incrementally from local variables (plus
the "self" concept), and then attributes are built on top of that.


David

--
David A. Black (dblack@wobblini.net)
Ruby Power and Light, LLC (http://www.rubypowerandlight.com)

"Ruby for Rails" PDF now on sale!  http://www.manning.com/black
Paper version coming in early May!
_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org