Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
question about class variables and instance variables
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Logan Capaldo, post: 4503436"] Classes are objects too. @strange is an instance variable of the object A (which has class, Class). @@strange is a class variable of the class A. The difference is that instances of A can peek at the class vars. They can't peek at A's instance vars. They are in two separate namespaces. The other difference is that class variables aren't so much class variables as they are class hiearchy vars. EG: class A @@strange = 1 end class B < A puts @@strange end #prints 1 class C @strange = 1 end class D < C puts @strange end # prints nil [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
question about class variables and instance variables
Top