Instance counter

2008/10/21 Robert K. [email protected]:

2008/10/21 Joel VanderWerf [email protected]:

Then you need an instance to set a class attribute.

I thought this was what you wanted since you can use @@foo inside instances.

I needed it from the class level, so Joel’s solution would be what I
needed.

Anyway, the point was to demonstrate that there is a clear and easy
solution that does not need class variables. Whether it’s mine or
yours does not really matter that much. I for my part would rather
have this solution (which is probably a bit more verbose than the
class variable solution) then resort to class variables because they
make code fragile because the declaration order matters.

I guess we have to agree to disagree here. To me the code shown was
neither more easy nor more clear than using class variables, but to
each his own. The declaration order of class variables didn’t matter
in my case. (In fact I think you have to invent some very special load
orders and class variable creation code to be hitten by this problem
in reality.)

Regards, and thank you and Joel for showing some alternatives,
Pit