Leave a rating/review
Notes: 20. Introduction
Update Notes: This course was originally recorded in 2019. It has been reviewed and all content and materials updated as of October 2021.
Sometimes in app development, you’ll find yourself needing to deal with a certain amount of clear cases… of something or another. As long as you can give a name to each one of those cases, you might be able to make use of an enumeration.
To define an enumeration, you start off with a keyword that is the first four letters of the word “enumeration”.
Some people pronounce that as “enoom”, which is what you’d call an “apocopation”: where you shorten a word by leaving off the end.
thers say “E-num”, because that’s what it literally looks like it spells. That’s similar to saying “varr”, even though it stands for “variable”.
oth ways are fine; take your pick or say it differently every time!
No matter how you say it, Enumerations let you take advantage of Swift’s type safety when you know you’ll only want a specific set of related, discrete values.
Enumerations are another kind of Named Type, like Classes and Structures! They’re also value types, like structures are. They can have things like methods and properties, which we’ll explore later on in the course. In this part, we’ll mostly explore functionality that’s specific to Enumerations.
We’ll also cover a new kind of control flow in this part of the course: The Switch Statement! Pair an Enumeration with a Switch Statement, and you have powerful new tool at your disposal.
So, let’s find out what you can do with an enumerations.