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

On Oct 5, 2013, at 13:01 , Doug J. [email protected] 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.

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.

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

... doug

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs