Gold Challenge

Create a new Person class with two properties: name and age. For convenience, create an initializer that provides arguments for both of these properties.

Next, create two new instances of the Person class. Assign those instances to two constants named p1 and p2. Also create an array named people to hold these instances and then put them inside the array.

You will occasionally need to find the index of an instance of a custom type within an array. Call the indexOf(_:) method on your array to do so. The argument takes the value of some element in the collection whose index you would like to find. Use the method to find the index of p1 inside of the people array.

You will get an error. Take some time to understand the ...

Get Swift Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.