Control Transfer Statements in Swift

break, continue, fallthrough, throw and return

Steven Curtis
The Startup

--

Photo by Patryk Grądys on Unsplash

Swift has five control transfer statments. What are they, and how can they be used?

  • continue
  • break
  • fallthrough
  • return
  • throw

Difficulty: Beginner | Easy | Normal | Challenging

Prerequisites:

Along with:

Terminology

break: Breaks the current execution whenever the keyword is encountered

continue: Stops the execution of a loop at the current point, and returns control to the next iteration of the loop

Control Transfer Statements: Keywords that allow you to transfer control from one piece of code to another

fallthrough: Make a Switch run the next case after a match

return: Make a function return

--

--