From the last few recipes on collection types, we have seen, that their elements are accessed through subscripts. However, it's not just collection types that can have subscripts; your own custom types can provide subscript functionality too.
Subscripts for custom types
Getting ready
Let's create a simple game of tic-tac-toe, also known as Noughts and Crosses. To do this, we need a three-by-three grid of positions, with each position being filled by either a nought from Player 1, a cross from Player 2, or nothing. We can store these positions in an array of arrays.
The initial game setup code uses the constructs we covered earlier, so we won't go into its implementation. Enter the following code into a new playground...