Hi, let me show the following code:
--------------------------
module M
@@var="M"
def var
@@var
end
def self.var
@@var
end
end
class A
include M
def var= v
@@var=v
end
end
a=A.new
a.var
=> "M"
a.var="A"
=> "A"
M.var
=> "A"
--------------------------
WHY is @@var replaced within M module? I do know that this behaviour
exists when inheriting classes, so a children class shares the class
variables of its parent class (which is a documented but undesirable
feature of Ruby). But I didn't expect it to occur using a module as
I'm not inheriting from a class.
In short, don't use class variables within a module, am I right?
Thanks a lot.
--
IƱaki Baz Castillo
<ibc / aliax.net>