On Dec 12, 2005, at 1:42 PM, ako… wrote:
@var = var
- when module method MyModule.mymethod creates module variable @var,
and no class mixes in this module, where is this variable created?
The instance variable belongs to MyModule, which is an object. In
particular, MyModule is an instance of the class Module. The instance
variable is unaffected by any usage of MyModule via include/extend.
- module variables become class variables for the classes that mix in
No. Instance variables are not propagated/shared via the class
nor via the mixin hierarchy.
so if the module method MyModule.mymethod changes module
variable @var then this variable is changed in all the classes/objects
that have this module mixed in. is this correct?
Instance variables are private to the associated object, they are not
Separate and distinct from instance variables are ‘class variables’
are shared via the class hierarchy. There are some subtle details of
sharing and in general you should view class variables and instance
as two very different beasts.