Programming in Swift: Functions & Types

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

Part 3: Enumerations

23. Switch Statements

Episode complete

Play next episode

About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 22. Challenge: Enumerations Next episode: 24. More Switch Statements

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: 23. Switch Statements

Update Notes: This course was originally recorded in 2019. It has been reviewed and all content and materials updated as of October 2021.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

At this point, you’re familiar with a few different ways of controlling the flow of execution in your apps: if statements, while loops, and for loops. Now, you’ll learn about one more method of control flow: switch statements.

func getSeason(
(for month: Month) -> Season {

if month == .december
.december || month == .january || month == .february {

return .winter
switch month 
switch month {

case .december
case .december😺:
  return .winter
case .december, .january, .february:
  case .march:
  case .april:
  case .may:
  case .june:
  case .july:
  case .august:
  case .september:
  case .october:
  case .november:
case .march, .april, .may:
    return .spring
case .june, .july, .august:
    return .summer
case .september, .october, .november:
    return .autumn
getSeason(for: .august)