Javatpoint Logo
Javatpoint Logo

Fallthrough Statement

Swift 4 fallthrough statementis used to simulate the behavior of Swift 4 switch to C/ C++ style switch. In Swift 4, the switch statementcompletes its execution as soon as the first matching case is completed unlike the C and C++ programming languages where falling through the bottom of subsequent cases happen.

Syntax of SwitchStatement in C/C++

In the above code, we need a break statement to come out of a case statement, otherwise the execution control will fall through the subsequent case statements available below the matching case statement.

Syntax of Switch Statement in Swift 4

In the above code, if we don't usefallthrough statement, then the program will come out of the switch statement after executing the matching case statement.

Let's see an example to make it clear.

Example: (Swift 4 example with fallthrough statement)

Let's see how to use a switch statement in Swift 4 without fallthrough statement:

Example 1:


JavaTpoint is an educational portal

Example 2:

Let's see how to use a switch statement in Swift 4 programming with fallthrough statement.


This is JavaTpoint
JavaTpoint is an educational portal

Next TopicSwift 4 Loops

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA