groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aarjav Patel <>
Subject Re: About supporting `var` of Java10+
Date Thu, 08 Mar 2018 19:46:39 GMT
Hi all,

I do not know all of the intricacies in the difference between current
groovy def and the proposed java var. However as a groovy 'user' coming
from a Javan background, I would like or expect var in groovy to be
treated/behave the same way as in java. def then would be an 'enhanced'
version of var which works better (?) with other language features. This
way there are less surprises when using var.

Unfortunately I have not looked at 2.5+ regarding lambdas. Are they just
another way to denote a closure? Just wondering how it was handled so that
maybe it can give us similar options for var/def.


- Aarjav

On Mar 8, 2018 8:58 AM, "mg" <> wrote:

> My argument was not in relation to the JEP, but a Groovy user story, in
> relation to you saying, that I would not see a difference between def and
> var, apart from when assigning a value later on.
> But assigning a value later on is _exactly_ what I am going to do when I
> use var - because otherwise I would use final instead of var...
> -------- Urspr√ľngliche Nachricht --------
> Von: Jochen Theodorou <>
> Datum: 08.03.18 13:32 (GMT+01:00)
> An:
> Betreff: Re: About supporting `var` of Java10+
> Am 08.03.2018 um 12:45 schrieb mg:
> > 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()
> That's what I understood. But the later variant is not part of the JEP.
> In Groovy what you wrote is an alias for final Object x = new Foo()
> bye Jochen

View raw message