From: jlr8 Date: 2005-11-26T02:47:28+09:00 Subject: Newbie Mixin Problem Hi, I'm new to Ruby and have done some reading on it. To learn more about it I'm attempting to re-write some of my Java code. However I have run into a problem with Modules/Mixins that I can't seem to solve. My problem is like this; I have a module with the instance method validIndex? (and some constants) which is included into my other classes; Board, Strategy and Player. module Common MAX_ENTRIES = 19682 def validIndex?(index) if index >= 0 && index <= MAX_ENTRIES then return true else return false end end end Each Player has two Strategies and Boards represent these. When creating a Board instance I can use validIndex?, however when creating a Strategy or Player (which creates new Boards) I get: NoMethodError: undefined method `validIndex?' for Board:Class from /Users/jon_r/Projects/RbNoughtsCrosses/Board.rb:31:in `numToBoard' from /Users/jon_r/Projects/RbNoughtsCrosses/Strategy.rb:13:in `initialize' from /Users/jon_r/Projects/RbNoughtsCrosses/Strategy.rb:12:in `each' from /Users/jon_r/Projects/RbNoughtsCrosses/Strategy.rb:12:in `initialize' from /Users/jon_r/Projects/RbNoughtsCrosses/Player.rb:15:in `new' from /Users/jon_r/Projects/RbNoughtsCrosses/Player.rb:15:in `initialize' from (irb):5:in `new' from (irb):5 But when I check each classes instance methods I see validIndex? listed. I'm confused, as in my eyes, it's similar to the who_am_i? example given in the book. However there is still a lot for me to learn. Does anybody recognise this situation, or where I'm going wrong? I'm sorry if it's stupid but I have tried to find solutions from other sources. Cheers. Jonathan