First, the operator introduces
运算符是一种特殊的符号,用以表示数据的运算、赋值和比较等。
1. 算术运算符;
2. 赋值运算符;
3. 比较运算符(关系运算符);
4. 逻辑运算符;
5. 位运算符。
Second, the arithmetic operators
Third, the relational operators (comparison operators)
basic introduction
1. 关系运算符的结果都是boolean型,也就是要么是true,要么是false;
2. 关系表达式 经常用在 if结构的条件中或循环结构的条件中;
3. 关系运算符的使用和java一样。
List of Relational Operators
detailed description
1. 关系运算符的结果都是Boolean型,也就是要么是true,要么是false;
2. 关系运算符组成的表达式,我们称为关系表达式。 a > b ;
3. 比较运算符“==”不能误写成“=”;
4. 使用陷阱: 如果两个浮点数进行比较,应当保证数据类型一致。
Fourth, the logical operators
用于连接多个条件(一般来讲就是关系表达式),最终的结果也是一个Boolean值。
List of logical operators
A variable is assumed true, B is false
Fifth, the assignment operator
赋值运算符就是将某个运算后的值,赋给指定的变量
Classified assignment operator
assignment operator characteristics
1. 运算顺序从右往左;
2. 赋值运算符的左边 只能是变量,右边可以是变量、表达式、常量值/字面量;
3. 复合赋值运算符等价于下面的效果
比如:a+=3 等价于a=a+3
Bitwise
otherwise specified operator
Scala不支持三位运算符 , 在Scala中使用if – else的方式实现。
val num = 5 > 4 ? 5 : 4 //没有
val num = if (5>4) 5 else 4
Learning From: Beijing Shangxue Tang Han Shunping teacher - Scala big data technologies in Silicon Valley is still
a little progress every day, maybe one day you will become so small! ! !