Wonderful job, we’ve successfully created our own data type using structures and modeled dogs, books, and birds in our code!

In this lesson, we covered:

  • Structures are a means of modeling real-life objects programmatically.
  • How to create a structure using the struct keyword along with properties and methods.
  • Structure properties are used to describe the characteristics and values of the structure.
  • To model individual objects, we can create instances of structs, which may have unique property values.
  • We can access and edit properties using dot notation.
  • If we know that most of our instances will have a specific property value, we can assign default property values inside the struct.
  • Using the init() method allows us to provide an instance with specific values for the structure’s given properties.
  • Even without an init() method, structs come with a default memberwise initialization method that can assign values to declared properties inside a struct.
  • Structures can have methods that are functions accessible to their instances.
  • Structures are value types, any copied struct that has its properties altered will not affect the original structure from which it was copied.



If you want to challenge yourself further:

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?