groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MG <>
Subject Re: Groovy Champions proposal feedback
Date Fri, 16 Feb 2018 19:28:55 GMT
On 16.02.2018 01:52, Jochen Theodorou wrote:
> final variables with no explicit type not being of type Object is the 
> case for type-checked variant and in normal Groovy it does not play 
> any role (not even the modifier does play a real role in the 
> compilation result)

The following holds also for the dynamic case: In my (Groovy) framework 
I need to be able to filter properties/fields of classes by type. E.g.

final foo1 = new MyClass(...)

will have type Object, so I have to filter it by looking at the type of 
the value stored in foo1.


final MyClass foo1 = new Foo(...)

I can filter by looking at the type of foo1 - but it requires the 
framework user to unecessarily supply the type in the field definition.

Ironically IntelliJ Intellisense of course knows that foo1 is of type 
MyClass also in the first case ;-)
Intellisense will also warn of "final" violations in the dynamic case, 
even if Groovy ignores the setting.
And as always the argument remains that declaring things which are final 
as final is good for other people reading your code :-)


View raw message