Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

Commit

Permalink
Start renaming square to position
Browse files Browse the repository at this point in the history
  • Loading branch information
edgenard committed Apr 3, 2018
1 parent 1dd3398 commit 6550657
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tic-tac-toe/tic_tac_toe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
@medwards1771

medwards1771 Apr 3, 2018

Contributor

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

Expand Down

0 comments on commit 6550657

Please sign in to comment.