语法糖表达式 | 实际调用函数 |
---|---|
a b | a.lus(b) |
a - b | a.minus(b) |
a * b | a.times(b) |
a / b | a.div(b) |
a % b | a.rem(b) |
a | a.inc() |
a-- | a.dec() |
a | a.unaryPlus() |
-a | a.unaryMinus() |
!a | a.not() |
a == b | a.equals(b) |
a > b | a.compareTo(b) |
a < b | a.compareTo(b) |
a >= b | a.compareTo(b) |
a <= b | a.compareTo(b) |
a..b | a.rangeTo(b) |
a[b] | a.get(b) |
a[b] = c | a.set(b, c) |
a in b | b.contains(a) |
Kotlin 运算符重载
2022-01-13 14:28:57
浏览数 (3)