Learn

Great job 🙌 We have learned about the power and flexibility offered by Swift enumerations. Here’s what we covered:

  • What an enumeration is
  • How to use enumerations in a switch control flow
  • How to iterate over enumerations cases like a collection
  • Defining raw values in an enumeration
    • Explicitly and implicitly assigning raw values
    • Extracting raw values for cases
    • Initializing an instance with a raw value
    • All cases must have the same type of raw value
  • Defining associated values in an enumeration
    • Associated values can be differently typed for each case
    • All cases don’t need associated value
  • Implementing methods in enumerations
    • Use of mutating methods
  • Defining computed properties in enumerations

Enumerations are indeed first class citizens in Swift and can help you write clean, expressive code 🛩

Instructions

Feel free to utilize the empty Review.swift file and output terminal on the right to hone your understanding of enumerations.

Click on “Up Next” when you’re ready to continue.

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?