官术网_书友最值得收藏!

  • Learning Scala Programming
  • Vikash Sharma
  • 107字
  • 2021-06-30 19:07:52

Relational operators

Relational operators are used to compare two operands. We have quite enough of these, ==, !=, >, <, >= and <=. Let's try them:

scala> val equal_op = 10 == 10
equal_op: Boolean = true

scala> val not_eq_op = 10 != 10
not_eq_op: Boolean = false

scala> val gt_than_op = 10 > 10
gt_than_op: Boolean = false

scala> val gt_than_op = 11 > 10
gt_than_op: Boolean = true

scala> val lt_than_op = 11 < 10
lt_than_op: Boolean = false

scala> val gt_eq_op = 11 >= 11
gt_eq_op: Boolean = true

scala> val lt_eq_op = 11 <= 11
lt_eq_op: Boolean = true

With these operators, we compare two operands for their values, and these operations yield a Boolean result.

主站蜘蛛池模板: 乌苏市| 家居| 平阴县| 吉林市| 江口县| 包头市| 色达县| 综艺| 葫芦岛市| 堆龙德庆县| 汕尾市| 林芝县| 且末县| 彭水| 教育| 马关县| 麻栗坡县| 大兴区| 昔阳县| 精河县| 剑川县| 阆中市| 大埔区| 嘉黎县| 宁远县| 大丰市| 任丘市| 肇庆市| 蛟河市| 富民县| 芦溪县| 安西县| 江油市| 溧阳市| 台北县| 滨州市| 萨嘎县| 凤冈县| 博野县| 大邑县| 天气|