groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Søren Berg Glasius <>
Subject Re: change in definition of Groovy?
Date Tue, 17 Nov 2015 19:15:33 GMT
Hi Ralph,

Had to fire up Groovy Console (2.4.5) and try it out:

class Obj {
   Map foo

obj = new Obj() = 'some value'

assert == null

I do not see an error, so unless I misunderstand your problem, I do not think it's wrong. 

To verify, I did the same with Groovy 2.1.9, same result. Then with Groovy 1.8.9, just to
be sure, also same result. 

PS: Just got to love when testing such code....

Best regards / Med venlig hilsen,
Søren Berg Glasius

Hedevej 1, Gl. Rye, 8680 Ry, Denmark
Mobile: +45 40 44 91 88, Skype: sbglasius
--- Press ESC once to quit - twice to save the changes.

On November 17, 2015 at 8:04:55 PM, Ralph Johnson ( wrote:

I am in the process of converting a large Groovy program from 2.1 to 2.4.   A year or two
ago I converted it from (I think) 1.8 to 2.1.

I found an odd assignment. = v

The code assumed that if was null, this assignment statement was skipped.   It does
not work that way in 2.4, and I had to rewrite it to make the code work.  I had no idea that
you could use the safe dereferencing operator on the left-hand-side of an assignment, I always
thought it was only on the right-hand-side.   I imagine that the author of this code was
exploiting a bug in Groovy, that Groovy was never supposed to allow this.   Somewhere between
2.1 and 2.4, this bug got fixed.    Or was there a change in the definition of Groovy?  
Or am I completely missing the point?

-Ralph Johnson
View raw message