Scala关系运算符

于2017-07-06由小牛君创建

分享到:


下面的简单示例程序演示的关系运算符。复制并粘贴到一个Test.scala文件中,编译并运行此Scala程序程序。

object Test {
   def main(args: Array[String]) {
      var a = 10;
      var b = 20;
      println("a == b = " + (a == b) );
      println("a != b = " + (a != b) );
      println("a > b = " + (a > b) );
      println("a < b = " + (a < b) );
      println("b >= a = " + (b >= a) );
      println("b <= a = " + (b <= a) );
   }
}

这将产生以下结果:

C:/>scalac Test.scala
C:/>scala Test
a == b = false
a != b = true
a > b = false
a < b = true
b >= a = true
b <= a = false

C:/>