i tried to replace methods and variables common to many classes by a
mixin. I attached the file that contains the module as well as the file
where the module is mixed in. Here is a short schematic version of what
i want to do.
module m @array = []
def add x
array.push x
end
end
class inner
include m
end
class outer
inner.new.add x
end
Here is the original error output.
./updatepaintmodule.rb:21:in addElement': undefined methodpush’ for
nil:NilClass (NoMethodError)
from ./layeredbg.rb:7:in initialize' from ./game.rb:35:innew’
from ./game.rb:35:in initialize' from ./main.rb:5:innew’
from ./main.rb:5
I think i saw an example where instance variables were mixed in. So, why
would they be nil?