Accessing class instance variable from instance method

Sorry. See subject. (To access class instance variable from inside
instance method).

My very small rant is, accessing class variables (@@var) from inside
instance method is much easier and more straightforward; however, I

tend

to use class instance variable more often, since in Ruby1.x @@var is
shared in subclasses (IIRC this will change in Ruby2). I've never find

a

use for @@var so far in my programs.

But you're trying to access a (private) variable on a completely
different, and only vaguely related, object. Why should you have a
"nice" way?
I don't often use @@var either. I use a class instance variable only
when it has to do with the internal mechanics of the object representing
the class, nothing for the objects instanciated from the class top muck
around with.

Mehr, Assaph (Assaph) wrote:

My very small rant is, accessing class variables (@@var) from inside instance method is much easier and more straightforward; however, I

tend

to use class instance variable more often, since in Ruby1.x @@var is shared in subclasses (IIRC this will change in Ruby2). I've never find

a

use for @@var so far in my programs.

But you're trying to access a (private) variable on a completely
different, and only vaguely related, object. Why should you have a
"nice" way?

Then perhaps Ruby should not provide a "nice" way to access @@var too :slight_smile:

ยทยทยท

I don't often use @@var either. I use a class instance variable only
when it has to do with the internal mechanics of the object representing
the class, nothing for the objects instanciated from the class top muck
around with.

--
dave