A Different Approach
Let’s learn how to use other data structures to make our board of tic-tac-toe.
We'll cover the following...
Making the board using a list of strings
What if we make one small change by representing the board as a list of lists of strings? Here are the commands for accessing and inserting elements:
Executable
Press + to interact
board = [ ["O", " ", " "],[" ", "X", " "],[" ", " ", " "] ]
Press + to interact
get_in(board, [Access.at(1), Access.at(1)])
Press + to interact
board = [ ["O", " ", " "],[" ", "X", " "],[" ", " ", " "] ]
Output
iex(1)> board = [ ["O", " ", " "],
...(1)> [" ", "X", " "],
...(1)> [" ", " ", " "] ]
[["O", " ", " "], [" ", "X", " "], [" ", " ", " "]]
iex(2)> get_in(board,
...