Let's get our hands dirty with some code. We can try using the template panel to implement a switch statement and a for loop. How do we do this?
- Let's open the Utilities panel. To do so, use the topmost right icon on the toolbar or simply press Option + cmd + 1.
- Then select the second tab in the bottom part {} to open the code snippets library.
- Next, type the following in the filter field—Swift switch.
- You should see just a single item.
- Drag that item to the editor:
- Once you drop it, you will see the switch structure with a few placeholders to fill in.
- Try to fill the gaps, so the switch looks something like this: