Hi,

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 method `push' for
nil:NilClass (NoMethodError)
  from ./layeredbg.rb:7:in `initialize'
  from ./game.rb:35:in `new'
  from ./game.rb:35:in `initialize'
  from ./main.rb:5:in `new'
  from ./main.rb:5

I think i saw an example where instance variables were mixed in. So, why
would they be nil?

Attachments:
http://www.ruby-forum.com/attachment/7897/updatepaintmodule.rb
http://www.ruby-forum.com/attachment/7898/layeredbg.rb


-- 
Posted via http://www.ruby-forum.com/.