Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Duplicate
-
None
-
None
Description
Look at this piece of code
groovy> class A
groovy> { def negate()
groovy> }
groovy>
groovy> def a= new A()
groovy> println ~a
Exception thrown: groovy.lang.BitwiseNegateEvaluatingException: Cannot bitwise negate type A, value A@5b02a6
groovy.lang.BitwiseNegateEvaluatingException: Cannot bitwise negate type A, value A@5b02a6
at Script0.run(Script0:10)
It would be really useful if it would call negate() on any type of object. It would help especially in the creation of DSL's since we are in shortcut of unary prefix operators