Operators are the most used in programming, including unary, two, and ternary three operators. Swift is just as basic as other programming languages, and here's a summary of it, as well as its unique operators. For example interval operators
1, unary operators
= assignment operator, the most used, with no matter what the return value
+ addition (numbers added, can also be used for character stitching var ss = "A" + "B")
- Subtraction
* Multiplication
/ Division
% redundancy (minus sign ignored, floating point can also be redundant)
> greater than
< less than
2, two-dollar operator
+ + + self-increment (that is, i = i + i abbreviation, can be pre-++i, able to post i++, is the same, the predecessor: self-increment and return. Back: Back to self-increment)
--Self- subtraction (equals i = i-i)
+ = i + = A is a shorthand for i = i + A
- = Ibid.
= = equals
! = does not equal
>= greater than or equal to
<= less than or equal to
3, ternary operator (trinocular operator)
= = = Identical to infer whether two objects refer to the same instance of an object
!== not identical
?: question? The answer is true: The question is a false answer such as Var a=0;print ("\ (a>0?
1:2) ") Output 2
a...b Full closed interval contains a and b
A.. <b semi-closed interval contains a does not contain B
4, logical operator. && | | Non-or (with and or the first condition satisfied will not calculate the second one.) This is a short-circuit calculation)
New operators:
1. The null-fit operator can be understood as a shorthand for the three-mesh operator
A??
B (A! = nil?)
A! : b), meaning that A is empty and return B is not NULL returns a.
"Swift" Learning Notes (ii)--basic operators