Knowledge Points:
- swift range Operator: < {means [x, y], that is, greater than or equal to X, less than y}, ... {means [x, Y], which is greater than or equal to X, less than or equal to Y} (primarily for the For loop)
- swift overflow operator ( Span style= "color: #E53333;" > Note: is provided for integral type Calculation ): &+, &-, &*, &/, &%
- swift supports n to n assignment
- swift assignment is no return value
- Span style= "line-height:1.5;font-size:12.5px;" >% in Swift is called the "redundancy Operator", and the positive and negative of the remainder result is the same as the positive or negative of the left value
- swift% Floating-point calculations are also supported
- bool type is similar to Boolean in Java, There are only two values of true and False
-
- if must be of type bool
Example code:
: Playground-noun:a place where people can playimport uikit//the newly added operator//range operator//in Swift < {means [x, y], that is, greater than or equal to X, less than y}, ... {means [x, Y], which is greater than or equal to X, less than or equal to Y} (mainly used for the For loop)//overflow operator//&+, &-, &*, &/, &%//1, Swift supports n assignment to n = (x, y) = (1, 2) //That is, X is assigned a value of 1,y is assigned to 2, and both constants//2, Swift Assignment is no return value//The following code is wrong, because x = y does not return the corresponding value//if (x = y) {}//3,% in Swift is called "redundancy operator" 9 4
//1-9% 4 // -19%-4 //1-9%-4 // -1//the positive or negative value of the residual result is the same as the positive or negative of the left number//Swift% also supports the calculation of floating-point numbers 8 2.5 //0.5//4, BOOL class Type is similar to a Boolean type in Java, only two values of true and false//in C are true, and in Swift there is no such concept//if the condition must be a value of type bool//The following error//if (1) {}//the correct if ( true) { println ("conditional")}//5, scope operator,: < and ... for i in 0..<5 { println (i)}//Output 0 to 4for I in 0...5 { println (i)}//Output 0 to 5//6, Swift provides 5 &am for integral type calculation p; The opening overflow operator, which can be flexibly processed for values beyond the range of values//NOTE: Here is a let n = uint8.maxlet m = n &+ 1let n1 = Uint8.minlet M1 = N1 &-1 for integral type calculation
Swift Learning-operators