The switch in Swift has been greatly improved in comparison with this part of the objective-c. This is a very interesting thing, because it is still not added to the objective-c, or the fact that the objective-c is a superset of C is not broken.
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/*
Next we will explain how to use the switch statement. The structure of the switch statement is as follows:
Switch (integer expression){Case integer constant 1:A series of statements // optionalCase integer constant 2:A series of statements //
Switch statements can be rewritten with if statements, but if statements cannot be rewritten with switch statements.
Public Enum staustype {// // link // linkinfo = 1} public static string getstaustype (staustype status) {string S = ""; Switch
The switch can only compare values or characters, but do not think that it is not useful if so. If appropriate, it is more efficient than if Else. The syntax structure of the switch is as follows:
Switch (variable name or expression ){
Case must
Let's stop talking about the difference between = and =. Everyone on Earth knows. Usually I am very careful. When there is 0, when there is no time, when determining whether it is false, I will use =. However, depressing things still
After a long time in the communication industry, I often find thatProgramIf .. else .. this nesting layer is quite deep in switch writing, so I was born with the idea of writing a general switcher, which isolates this strong coupling writing method,
1. Switch parameter typeThe switch parameter type requirement is an integer type, which, to be exact, is a type that can be converted to an integer, which includes all C basic data Types ((signed/unsigned)char, (short/long signed/ Unsigned)int,
Code is very simple, I do not have much nonsense here, small partners directly look at the source bar.
Copy Code code as follows:
dynamically change hyperlink text and address
Please select
Please select
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
You cannot use the switch statement in ASP, you need to use the Select Case statement
A Brief introduction
Select the work of the report, if the statement. The difference, however, is that they can check for multiple values. Of course, you
A C#/cshorp switch statement is a control statement that handles multiple selections and enumerations by passing control to a case statement within its bodyint caseswitch = 1;Switch (Caseswitch){Case 1:Console.WriteLine ("Case 1");BreakCase
1. Operators and expressions-2
1.1. Value assignment
1.1.1. Use "=" for value assignment
"=" Is called the value assignment operator and is used to assign values to variables. In addition to assigning the expression on the right to the left, the
The fundamental difference between switch...case and If...else is that switch...case generates a jump table to indicate the address of the actual case branch, and the index number of the jump table is equal to the value of the switch variable. Thus,
The game usually contains a variety of functions, such as combat system, UI rendering, economic system, production system, etc., each system contains a variety of sub-functions, such as damage determination, cast, use props, character movement,
1. Compound assignment operator + = = *=/=%=2. Relational operators > = 3, BOOL type we use the bool type in C # to describe the right or wrong. type bool has only two values, one is true and one is False4. Logical operator logic with && (shift+7)
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.