Basic Operators
最后更新于:2022-04-01 02:47:38
## Basic Operators
Unlike C, Swift lets you perform remainder (%) calculations on floating-point numbers.
~~~
if x = y {
// this is not valid, because x = y does not return a value
}
// Swift中的取模操作
-9 % 4 // equals -1,理解成:-9 = (4 × -2) + -1
~~~
Swift also provides two identity operators (=== and !==), which you use to test whether two object references both refer to the same object instance
~~~
// ???
var arr1 = [1, 2, 3]
var arr2 = arr1
arr2[0] = 10;
arr1 // [10, 2, 3]
arr2 // [10, 2, 3]
arr1 === arr2 // 修改arr2,arr1也跟着修改,所以应该是指向一个object,这里应该是true,但结果却是false
~~~