groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <blackd...@gmx.org>
Subject Re: [Proposal] GString is implemented eager and treated as normal String since groovy 3.0.0
Date Mon, 10 Sep 2018 18:33:06 GMT
On 10.09.2018 18:51, Alessio Stalla wrote:
> Yes, but a toString method with side effects is a really bad coding 
> practice that won't be fixed simply by reducing the power of GString. 

well...

> class Wrapper {
>   def x
>   String toString(){x}
> }
> 
> def w = new Wrapper(x:1)
> def gstring = "$w"
> assert gstring == "1"
> w.x = 2
> assert gstring == "2"
> w = new Wrapper(x:3)
> assert gstring == "2" 

I don't think that example really falls under your really bad coding. 
You have this problem with lists and maps all the time

bye Jochen

Mime
View raw message