bin/main.rb
# for this method we need to check if the child arrays of the COMBOS array contain the same token
# inside of each of their spaces, i.e. that the space occupied by the first position of the child array
# contains the same token as the space occupied by the second position of the child
# array, and that the third position's space mathces the two ones. additionally the method will
# check with the *empty_space?* method to determine if a space is not empty and that is
# using the token used in the three positions of the child array
# we'll use the *detect* enumerable method. this method outputs the first entry on our enumerable for which the
# block conditions are true. in this case that position[0]== position[1] && position[1] == position[2] &&
# empty_space?(position[0])
for this method we need to check if the child arrays of the COMBOS array contain the same token
inside of each of their spaces, i.e. that the space occupied by the first position of the child array
contains the same token as the space occupied by the second position of the child
array, and that the third position's space mathces the two ones. additionally the method will
check with the *empty_space?* method to determine if a space is not empty and that is
using the token used in the three positions of the child array
we'll use the *detect* enumerable method. this method outputs the first entry on our enumerable for which the
block conditions are true.
for this method we need to check if the child arrays of the COMBOS array contain the same token inside of each of their spaces i . e . that the space occupied by the first position of the child array contains the same token as the space occupied by the second position of the child array and that the third position ' s space mathces the two ones . additionally the method will check with the * empty_space? * method to determine if a space is not empty and that is using the token used in the three positions of the child array we ' ll use the * detect * enumerable method . this method outputs the first entry on our enumerable for which the block conditions are true .
def won?
    COMBOS.detect do |combos_child|
      @board[combos_child[0]] == @board[combos_child[1]] &&
        @board[combos_child[1]] == @board[combos_child[2]] &&
        empty_space?(combos_child[0])
    end
  end
def won? COMBOS . detect do | combos_child | @board [ combos_child [ 0 ] ] == @board [ combos_child [ 1 ] ] && @board [ combos_child [ 1 ] ] == @board [ combos_child [ 2 ] ] && empty_space? ( combos_child [ 0 ] ) end end
for this method we need to check if the child arrays of the COMBOS array contain the same token
inside of each of their spaces, i.e.
for this method we need to check if the child arrays of the COMBOS array contain the same token inside of each of their spaces i . e .