One of the first projects I did in Elixir was a multiplayer Tic Tac Toe game using Phoenix. I stored the board as a string with nine characters (a character for each spot on the board).
”-“ = Open spot
“x” = Taken by X
“o” = Taken by O
After every move, the board state would have to be checked to see the state of the game. I implemented this check using one of Elixir’s strengths, string matching. This is a good example of how to use string matching because it shows how to match specific parts in a string which to me wasn’t obvious at first.
The important things to know for string matching are: