samples/05_mouse/01_mouse_click/app/main.rb
# Defines filled spaces on the board by rejecting all spaces that do not have game pieces in them.
# The ! before a statement means "not". For example, we are rejecting any space combinations that do
# NOT have pieces in them.
Defines filled spaces on the board by rejecting all spaces that do not have game pieces in them.
The . before a statement means "not". For example, we are rejecting any space combinations that do
NOT have pieces in them.
Defines filled spaces on the board by rejecting all spaces that do not have game pieces in them . The . before a statement means " not " . For example we are rejecting any space combinations that do NOT have pieces in them .
def filled_spaces
    state.space_combinations
      .reject { |x, y| !state.spaces[x][y].piece } 
      .map do |x, y|
        if block_given?
          yield x, y, state.spaces[x][y]
        else
          [x, y, state.spaces[x][y]] 
        end
    end
  end
def filled_spaces state . space_combinations . reject { | x , y | ! state . spaces [ x ] [ y ] . piece } . map do | x , y | if block_given? yield x , y , state . spaces [ x ] [ y ] else [ x , y , state . spaces [ x ] [ y ] ] end end end
Defines filled spaces on the board by rejecting all spaces that do not have game pieces in them.
Defines filled spaces on the board by rejecting all spaces that do not have game pieces in them .
# reject spaces with no pieces in them # sets definition of space