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

  • 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.

主站蜘蛛池模板: 甘孜县| 托克逊县| 平塘县| 兴化市| 松原市| 九龙城区| 昌宁县| 浦县| 白城市| 陕西省| 吉安县| 两当县| 武城县| 北川| 温宿县| 长乐市| 镇江市| 正安县| 浦东新区| 历史| 儋州市| 车致| 平定县| 常德市| 会泽县| 历史| 逊克县| 全南县| 舞阳县| 玉树县| 正蓝旗| 张家界市| 鹤山市| 攀枝花市| 南木林县| 武清区| 三原县| 澄城县| 深圳市| 杭锦后旗| 石河子市|