groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MG <>
Subject Re: Omitting parentheses on .size() ?
Date Wed, 05 Aug 2020 14:26:00 GMT
Thank you, Jochen - that's actually a Groovy feature that has been 
around for a long time, that I completely forgot about :-)

Do you know if:

 1. This works for interfaces (e.g. List and Map) ?
 2. Whether IntelliJ picks up those extension methods (i.e. will
    Intellisense know that e.g. List now has a getSize() method) ?


On 05/08/2020 09:34, Jochen Theodorou wrote:
> On 04.08.20 16:13, MG wrote:
>> On 04/08/2020 15:16, Basurita wrote:
>>> On 8/1/20 14:41, MG wrote:
>>>> Hmmm, I am for consistency, but at least I use very few maps as
>>>> compared to lists, and rarely ever output the size of a map, but
>>>> constantly for
>>>> lists, so having getSize() on List would still be beneficial.
>>> You're free to add whatever you want to your metaClass :-)
>> In dynamic Groovy, yes, but I am an IntelliJ / @CompileStatic Groovy
>> user so afaiaao there is no way to make this work in my case...
> for @CompileStatic this can be done via extension methods.
> Afaik it is still the case, that the classes containing extension
> methods must be compiled before their use in a separate compilation so
> the compiler can pick them up as part of the compilation once you want
> to use them.
> bye Jochen

View raw message