Alibabacloud.com offers a wide variety of articles about fallthrough in switch case statement, easily find your fallthrough in switch case statement information here online.
In Swift's switch, the case is followed by the use of Fallthrough, which is the same as the usage without break after OC case!The use of Fallthrough should be noted:1. When Fallthrough is added, the following case or default statement will be run
In the switch structure of Swift, note the usage of fallthrough. switchfallthrough
In the swift switch, the use of fallthrough is added after the case, which is the same as that of the case of OC without break!
Note the following when using
The switch statement in Swift, as long as the first match (case) completes, not through the bottom of subsequent cases (case), as it does in C and C + + programming languages. The following are common syntax for switch statements in C and C + +:
The Switch...case statement in Swift can determine the object type, and the objective-c must be an integer.Can not penetrate, can not write break,
var rank = "A"
switch rank{case
"a"://equivalent to if
print ("excellent") Case
The switch in Swift does not automatically fall from the previous case branch to the next one, if it is determined that this effect can be used in each case branch that requires the attributeFallthrough keywords//throughLet integer =5var desc="The
Grammarsyntax for switch statements in the Swift language:
Copy Code code as follows:
Switch Expression {
Case expression1:
Statement (s)
Fallthrough/* Optional *
Case Expression2, Expression3:
Statement (s)
Fallthrough/*
Switch as an essential statement in the selection structure is also added to Swift, as long as people with programming experience are not unfamiliar with switch statements, but Apple has greatly enhanced the switch to have features that are not
This is a creation in
Article, where the information may have evolved or changed.
Depending on the incoming condition, the SELECT statement executes a different statement. The following example prints a different content based on the input integer
Tag: swift IOS objective-C
Condition Statement
It is usually very useful to execute specific code according to specific conditions. For example, when an error occurs, you may want to run additional code; or, when the input value is too large or too
In the code business, conditional judgment is essential, and the statements that control the flow are similar in each language. Swift includes the following:If,switch,for-in,for,while,do-whileIf condition statement (if-else) (If ... else)Executes
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.