I have some modules in which I would like to use instance variables. I am currently initializing them as follows:
module MyModule def self.method_a(param) @var ||= 0
I could also call the init method to initialize them:
def init @var = 0 end
but that will mean that I must remember, to always call him.
Is there a better way to do this?
ruby module instance-variables
Geo Mar 30 '09 at 17:56 2009-03-30 17:56
source share