Permalink
Browse files

Start renaming square to position

  • Loading branch information...
edgenard committed Apr 3, 2018
1 parent 1dd3398 commit 6550657318edb3ebed346b97f2fbc15be9ac0fd1
Showing with 5 additions and 5 deletions.
  1. +5 −5 tic-tac-toe/tic_tac_toe.rb
@@ -26,14 +26,14 @@ def winning_move?(square, player)
end

def winner
rows = [0, 3, 6]
rows.each { |row| return winning_player(row) if winning_player(row) }
first_position_in_rows = [0, 3, 6]

This comment has been minimized.

@medwards1771

medwards1771 Apr 3, 2018

Collaborator

I'm glad you renamed this

first_position_in_rows.each { |position| return winning_player(position) if winning_player(position) }
return '-'
end

def winning_player(square)
if board[square] != '-' && board[square] == board[square + 1] && board[square + 1] == board[square + 2]
return board[square]
def winning_player(position)
if board[position] != '-' && board[position] == board[position.next] && board[position.next] == board[position.next.next]
return board[position]
end
end

0 comments on commit 6550657

Please sign in to comment.