In the following code I am trying to print out the value of the
variable @symbol from an array of instances of the MapSector class. I
don't understand why I'm getting "NoMethodError: undefined method
`symbol' for #<Array:0xb7cb025c>" after putting this in irb and typing:
foo = GameMap.new(5,5)
foo.show_map


class GameMap
  attr_accessor :height, :width, :id, :sectors
  def initialize height, width
    @height = height
    @width = width
    @id = nil
    @sectors = Array.new(@height, MapSector.new) {Array.new(@width,
MapSector.new)}
  end

  def show_map
    @sectors.each do |x|
      puts x.symbol
    end
  end

end

class MapSector
  attr_accessor :type, :symbol, :players
    def initialize
    @type = "plains"
    @players = []
    @symbol = "."
  end
end
-- 
Posted via http://www.ruby-forum.com/.