Maybe I am missing your point, but what I meant was: When I use
var x = new Foo()
I indicate that x will be reassigned further down in the scope, otherwise I use
final x = new Foo()
PS: I know all the Groovy samples in the documentation use def instead of final 
all the time, even though no reassignment takes place. Evidently I do not agree 
with that - even where final is not really enforced by Groovy, the 
documentation aspect remains (and at least Intellisense will warn you when 
reassigning to a final field/variable/parameter) :-)


-------- Ursprüngliche Nachricht --------Von: Jochen Theodorou 
<blackd...@gmx.org> Datum: 08.03.18  10:57  (GMT+01:00) An: 
dev@groovy.apache.org Betreff: Re: About supporting `var` of Java10+ 


Am 08.03.2018 um 09:44 schrieb mg:
> @unless you reassign, you would not notice the difference between current
> def and the Java var:
> 1) If I don't need to reassign, I would use final instead of var :-)
> 2) Supporting var for fields that get initialized during declaration, 
> also would feel very Groovy to me, although I personally would not 
> expect to use that a lot.

they decided against using final and instead go with semi-final.

bye Jochen

Reply via email to