Groovy中的操作符重载

 

操作者 方法

a + b

a.plus(b)中

a - b

a.minus(b)中

a * b

a.multiply(b)中

a ** b

a.power(b)中

a / b

a.div(b)中

a % b

a.mod(b)中

a | b

a.or(b)中

a & b

a.and(b)中

a ^ b

a.xor(b)中

a++ 要么 ++a

a.next()

a-- 要么 --a

a.previous()

a[b]

a.getAt(b)中

a[b] = c

a.putAt(b,c)

a << b

a.leftShift(b)中

a >> b

a.rightShift(b)中

a >>> b

a.rightShiftUnsigned(b)中

switch(a) { case(b) : }

b.isCase(a)中

if(a)

a.asBoolean()

~a

a.bitwiseNegate()

-a

a.negative()

+a

a.positive()

a as b

a.asType(b)中

a == b

a.equals(b)中

a != b

a.equals(b)中

a <=> b

a.compareTo(b)中

a > b

a.compareTo(b)> 0

a >= b

a.compareTo(b)> = 0

a < b

a.compareTo(b)<0

a <= b

a.compareTo(b)<= 0

 

猜你喜欢

转载自www.cnblogs.com/jsersudo/p/10337873.html