Accessing a Class Variable from an Instance

It appears (to me) that if one wants to access a class variable from an
instance method, accessor methods need to be provided. Am I missing
anything on this? Thanks.

      ... doug

···

--
Posted via http://www.ruby-forum.com/.

Class variable? (@@var): no. You can simply access it.

Class INSTANCE variable? (@var, at class scope): absolutely, you must define accessor methods.

IMHO, you should be accessing ALL state (instance or class) via accessor methods. This makes refactoring and changing the design _much_ easier.

···

On Oct 5, 2013, at 13:01 , Doug Jolley <lists@ruby-forum.com> wrote:

It appears (to me) that if one wants to access a class variable from an
instance method, accessor methods need to be provided. Am I missing
anything on this? Thanks.

Thanks so much. I got it. I think that I'm loosing it down here. :slight_smile:

    ... doug

···

--
Posted via http://www.ruby-forum.com/.