Summary
This chapter went in-depth in to how we can use for-in loops to solve certain problems in our code. Along with for-in loops, we were shown how to use if-else statements, which help us write code to satisfy certain conditions. These are two very powerful tools in Swift.
We now have a pretty clear understanding as to what a type in Swift is. We've seen types, such as String
, Int
, Array
, and Dictionary
, but what if we want to make our own custom type? We will be going through how to create our own custom types in the next chapter.
For example, if we want a type in our code to represent a Person, we will create our own Person type. An instance of this type would have a name and an address, along with a favorite ice cream flavor! It can also walk, run, and sleep. It sounds like we can solve this problem with variables and functions. This is what we will be covering in the next chapter.