With the help of
fallthrough statement, we can use to transfer the program control just after the statement is executed in the switch cases even if the expression does not match. Normally, control will come out of the statement of switch just after the execution of first line after match. Don’t put the fallthrough in the last statement of switch case.
Example 1: In this example we can see that by using switch cases with fallthrough and assuming variable as a string type we can make use of switch cases.
Geek For Geeks
- Golang program that uses defer keyword
- Golang Program that uses String Switch
- Golang program that uses structs as map keys
- Golang program that uses switch, multiple value cases
- Golang program that uses func with variable argument list
- Golang program that uses func with two arguments
- Golang Program that Uses Named Return Values and Defaults
- Golang Program that Uses Multiple Return Values
- Golang Program that uses func as Local Variable
- Difference between var keyword and short declaration operator in Golang
- Defer Keyword in Golang
- Range Keyword in Golang
- How to instantiate Struct using new keyword in Golang?
- Header files in C/C++ and its uses
- How to implement is functionality without using is keyword in C#
- Global keyword in Python
- Invoking an overloaded constructor using this keyword in C#
- Throw Keyword in Scala
- var keyword in Go
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.