|NO.Z.00008|——————————|BigDataEnd|——|Hadoop&Scala.V08|——|Scala.v08|Scala编程|操作符|

一、操作符
### --- 操作符

~~~     Scala的算术操作符、位操作符与 Java中的效果一样的。
~~~     需要特别注意一点:Scala中的操作符都是方法
~~~     书写时推荐使用:a + b 、1 to 10这种代码风格。
~~~     Scala 没有提供 ++、-- 操作符,但是可以使用+=、-=
### --- a + b 等价 a.+(b)

scala> 1 + 2
res25: Int = 3

scala> 1.+(2)
res26: Int = 3
### --- 1 to 10 等价 1.to(10)

scala> 1 to 10
res27: scala.collection.immutable.Range.Inclusive = Range 1 to 10

scala> 1.to(10)
res28: scala.collection.immutable.Range.Inclusive = Range 1 to 10

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

posted on 2022-04-11 19:33  yanqi_vip  阅读(12)  评论(0)    收藏  举报

导航