Basic operator: almost all c operator with detecting overflow underflow errors.
If want to use overflow underflow then us overflow operator i.e & with that operatorEx:
a &+ b
% (Modulus operator) can be used on floating point . remainder always took sign of first number.
Range operator:
1)Closed range operator : a…b i.e start from a to equal to b
2)Half open range operator: a..<b start from a and less than b (equal to b-1).
unLike c assignment operator does not return value. (In C a=10 then return value is 10 in swift only assignment)
Support shorthand i.e += , -= etc.
Comparison operator same like c with extra === and !== . These two operator is used to test for two object reference refer to same object instances.
Tuples with less than seven elements can be compared , comparison is from left to right.
Nil coalescing operator: (a ?? b) : this unwraps an optional “a” if it contains a value or returns default value “b” if “a” is nil. b is same of a’s data type.
Logical operator(&& , || , !) is same with same optimisation like c.
0 comments:
Post a Comment