Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
combine loops into one
  • Loading branch information
edgenard committed Apr 2, 2018
1 parent 1885386 commit 1d39354aefb2153221fbec431c2b86941b3fe761
Showing with 1 addition and 2 deletions.
  1. +1 −2 tic-tac-toe/tic_tac_toe.rb
@@ -15,13 +15,12 @@ def best_move_for(player)
if square_unoccupied?(square)
move = square if winning_move?(square, player)
end
end

This comment has been minimized.

Copy link
@medwards1771

medwards1771 Apr 3, 2018

Contributor

how did you know that you could remove the second loop and still get the same result?

SQUARES_ON_BOARD.each do |square|
if square_unoccupied?(square)
move = square if move == NO_MOVE
end
end

return move
end

0 comments on commit 1d39354

Please sign in to comment.