Scala 关系运算符
尝试下面的示例程序,了解Scala编程语言中的所有关系运算符。
示例
object Demo {
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) );
}
}
将以上程序保存在 Demo.scala 中。使用以下命令来编译和执行该程序。
命令行
>scalac Demo.scala
\>scala Demo
输出
a == b = false
a != b = true
a > b = false
a < b = true
b >= a = true
b <= a = false