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

Commit 4ccb073

Browse files
committed
Add position occupied method
1 parent 194ce3a commit 4ccb073

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tic-tac-toe/tic_tac_toe.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ def winner
3232
end
3333

3434
def winning_player(position)
35-
if board[position] != '-' && board[position] == board[position.next] && board[position.next] == board[position.next.next]
35+
if position_occupied?(position) && board[position] == board[position.next] && board[position.next] == board[position.next.next]
3636
return board[position]
3737
end
3838
end
3939

4040
def position_unoccupied?(position)
4141
board[position] == '-'
4242
end
43+
44+
def position_occupied?(position)
45+
board[position] != '-'
46+
end
4347
end

0 commit comments

Comments
 (0)