Obviously @my_var and @@my_var are two separate entitites, but are
similar
in many ways. I have some questions around them, any help is
appreciated.
In terms of the figure in the PickAxe book 2nd Ed (page 381, lucille,
Guitar etc), where would these two variables ( @my_var and @@my_var )
appear?
If I have a subclass -
class B < A
end
the @@my_var is shared between the parent and child but @my_var is a
separate instance in each of them. Are there any other such differences?
As I have written accessor for @my_var, it most likely becomes a
method
in the virtual class A’, is there any way to write accessor for @@my_var
using Module’s attr_accessor method?
As a general guideline where would I use one or the other?
In terms of the figure in the PickAxe book 2nd Ed (page 381, lucille,
As a general guideline where would I use one or the other?
Thanks
Nasir
Class variables are evil. A smarter man than me said something on the
subject of class variables on this list recently. So, hopefully that
answers number 4. I’ll leave it to the non noobs to answer the others.