Programming in Swift: Functions & Types

Jan 4 2022 Swift 5.5, iOS 15, Xcode 13

Part 3: Enumerations

23. Switch Statements

Lesson Complete

Play Next Lesson
Save for later
About this episode
See versions

See course reviews

See forum comments
Cinema mode Mark as Complete Download course materials
Previous episode: 22. Challenge: Enumerations Next episode: 24. More 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.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a Professional subscription.

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)