You are not overriding the operator >=
, you are implementing compareTo
:
class Foo implements Comparable {
int val
int compareTo(Object o) { return val <=> ((Foo) o).val }
}
f1 = new Foo(val: 5)
f2 = new Foo(val: 10)
println f1 <= f2
=> true
source
to share