Tic-tac-toe bracket-methods do not work

Hey there. I set out to prove that the bracket methods explained in the tic tac toe exercise do not work. Here’s my code:

class Board

attr_reader :grid

def initialize
@grid = Array.new(3) { Array.new(3) }
end

def
row, col = pos
@grid[row][col]
end

def []=(pos, mark)
row, col = pos
@grid[row][col] = mark
end

def test(pos)
@grid[pos]
end
end

board = Board.new
pos = [0,0]
board.test(pos) # => error, no implicit conversion of array into integer

Since this code is copy-pasted from the bracket-methods.pdf, clearly there is an issue with the info provided. This test was done in ruby (2.3.1) as well as the latest release (2.5.0)

The correct way to access these bracket methods would be to omit the @grid when calling. For example, to fix the above:

class Board

  attr_reader :grid

  def initialize
    @grid = Array.new(3) { Array.new(3) }
  end

  def 
    row, col = pos
    @grid[row][col]
  end

  def []=(pos, mark)
    row, col = pos
   @grid[row][col] = mark
  end

  def test(pos)
    self[pos]
  end
end

board = Board.new
pos = [0,0]
board.test(pos) # => nil