I had a look at this question here. The problem with this question is this line:
Integer i3 = (Integer) -128; /*** Doesn't compile ***/
As some of the answer's say's:
The compiler interprets the - as the two-arg minus operator, i.e. it's trying to subtract 128 from some other number named Integer, but there's no such variable in scope
The answers look correct for me. Now in groovy I tried the same code as such before :
Integer i3 = (Integer) -128; /*** compiles!!! ***/
even this code of line compiles:
Integer i3 = (Integer) -(128); /*** compiles ***/
How does Groovy performing this operation? Does all Jvm languages does this? Whats happening behind the scene's in case of Groovy.
Does this doesn't break Java rule? Bit confused.
For reference I have tagged the working Groovy code here
Thanks in advance.