Collection types
All year, you've been dreaming of finally taking that family vacation to the moon. Marisa (your neighbor) went last year and it's all she ever talks about. After begging your parents to take you and your sister to the moon for a family vacation, you awoke to see this note slipped through your door.
Yes! We're going to the moon. On second thoughts, now that we're finally going, it does sound a little scary to be leaving everything behind for a full month. Also, we need to reply by writing Swift code, that doesn't seem too bad.
In the earlier chapters, we've learned that there are various types built into the Swift language:
let name = "Jim" let age = 21
Here, name
is a constant of the String
type and age
is a constant of the Int
type. They have both been assigned values: name
has been assigned the value Jim
and age
has been assigned the value 21
. Let's get back to the note we received now. It's asking us to create a list. What we need to do is generate a list of values...