I have
board_a1 = " [ ] "
board_a2 = " [ ] "
board_a3 = " [ ] "
etc. I prompt the user, and get input:
puts "Choose your square"
user_input = gets.chomp.downcase
If the user types in "a2", I need to reassign board_a2:
board_a2 = " [X] "
How would I match the user input to reassign the proper board square? I thought I could concatenate the pieces like so:
board_assignment = "board_#{user_input}"
Then use
board_assignment = " [X] "
But board_assignment != board_a2. It's a new variable. I need to reassign the proper variable based on the user input right after the user types it in. Is there some special syntax to concatenate strings that can then represent the existing variable? What do you call this situation, and how would I go about getting my dynamic variable set?