Woohoo! You’ve now added classes to your Swift toolbox. 🙌

With structures and classes being so darn similar, when do we use structures and when do we use classes?

The rule of thumb is to always use struct to start, and change it to class if inheritance is needed or use class instances for their reference typing.

In this lesson, we covered:

  • A class is another means of modeling real-life objects programmatically.
  • How to create a class using the class keyword.
  • Using the init() method allows us to provide an instance with specific values right off-the-bat during the creation of an instance.
  • A class can inherit another class’s properties and methods.
  • When using inheritance, the subclass can use the override keyword to redeclare a method with the same name.
  • Classes are reference types, any copied class that has its properties altered will affect the original class from which it was copied.


Oh, wait, what’s happening… We have officially made it to the end of this course?! 😱😱😱

Take a look at Letter.swift. Does it look familiar? This is the letter that you wrote to yourself at the very beginning of this course!

Here’s a letter from the Learn Swift team:

Dear Learner,

Um, congratulations!

You have officially finished the last Swift language lesson of this course. Give yourself a big pat on the back, because you have come so far in this journey and you should be very proud of yourself.

By giving this letter back to you, we hope that you will hold on to the old you that was first learning how to write a print() statement, the you that was curious and spirited, the you that was ready to tackle the world.

We hope that with Swift at your side, you will build something that can impact the world in a very positive way.

Take care and <3

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?