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

Commit

Permalink
combine loops into one
Browse files Browse the repository at this point in the history
  • Loading branch information
edgenard committed Apr 2, 2018
1 parent 1885386 commit 1d39354
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions tic-tac-toe/tic_tac_toe.rb
Expand Up @@ -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

Expand Down

0 comments on commit 1d39354

Please sign in to comment.