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?
A class is a module. So the statement should be: don't use class
variables period.
Right. Is it not planned to change the behaviour of class variables in Ruby?
I have no idea, you might ask at ruby-core. But there is quite a
consensus not to use them. What is your use case?
As much as I can guess from your example code, class instance
variables should do the trick for you.
e.g.
module A
class << self
attr_accessor :a
end
end
HTH
Robert
···
On Fri, Jul 29, 2011 at 12:32 PM, Iñaki Baz Castillo <ibc@aliax.net> wrote:
2011/7/29 7stud -- <bbxx789_05ss@yahoo.com>:
--
Iñaki Baz Castillo
<ibc@aliax.net>
--
I'm not against types, but I don't know of any type systems that
aren't a complete pain, so I still like dynamic typing.
--
Alain Kay
Yes, I try to use instance variables (but let's say "class's instance
variables" rather than "class instance's instance variable" XDD).
I was just wondering.
Thanks a lot.
···
2011/7/29 Robert Dober <robert.dober@gmail.com>:
I have no idea, you might ask at ruby-core. But there is quite a
consensus not to use them. What is your use case?
As much as I can guess from your example code, class instance
variables should do the trick for you.