Log in from a computer to take this course

You'll need to log in from a computer to start Learn Swift. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
Learn

Instances are how we create individual objects using a structure. In the previous exercise’s example, we created a structure to model dogs:

struct Dog { var age = 0 var isGood = true }

In Dog, we’ve modeled some general traits dogs have. However, each dog is unique in their own way — to represent this programmatically, we have to create different instances of dogs!

var eloise = Dog()

In the example above we’ve created a single instance of the Dog struct by adding parentheses () to Dog and save it to the eloise variable.

Instructions

1.

Given the Book structure, create an instance of Book and save it to a variable called myFavBook.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?