Chapter 3. Taking Control
In the last chapter, you spent some time getting to know Swift’s collections: arrays and dictionaries. Then you started looking at ways to iterate through those collections. In this chapter, you’ll continue looking at iteration and then move on to Swift’s ability to take directions on what to do at specific intervals.
If you haven’t already done so, start up the REPL in the Terminal application (remember, you can type
xcrun swift to get it going). The line numbers in the figures in this chapter assume that you are starting with a fresh REPL session.
For What It’s Worth
As you saw in the previous chapter, Swift’s ability to iterate through a collection, be it an array or a dictionary, uses the
for-in loop. Other variations ...