Programming in Swift: Functions & Types

Jan 4 2022 · Swift 5.5, iOS 15, Xcode 13

Part 3: Enumerations

20. Introduction

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: Part 2 Quiz: Closures Next episode: 21. Enumerations

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

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.

Transcript: 20. Introduction

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.