G
German Monfort
El Lunes, 30 de Abril de 2007 19:15, Gary Wright escribi=F3:
OK, I now understand the difference.
Probably I'm too new to programming to understand the full power of class=20
variables, and I found this concept a little bit dangerous because you can=
=20
affect the whole behavior of a class by simply changing a class variable in=
=20
any other subclass ... so I try not to use class variables for noiw.
I still need to read more and more![Big Grin :D :D](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Thanks Gary
I was illustrating the fact that C and E don't share the same @@bar
due to
initialization order and the location of the definitions of C.bar and
E.bar.
If you called D.new.foo you would get 43 because @@foo is shared by
C, D, and E
and was updated to reference 43 in the class block that defined E.
If you called D.new.bar you would get 45 because the call to 'bar'
would be
implemented by the definition in C where @@bar refers to C's @@bar.
This is
a good example of how class variables are not relative to self!
Gary Wright
OK, I now understand the difference.
Probably I'm too new to programming to understand the full power of class=20
variables, and I found this concept a little bit dangerous because you can=
=20
affect the whole behavior of a class by simply changing a class variable in=
=20
any other subclass ... so I try not to use class variables for noiw.
I still need to read more and more
Thanks Gary