groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Karr <davidmichaelk...@gmail.com>
Subject Re: @Delegate and Date
Date Tue, 25 Oct 2016 21:40:54 GMT
On Tue, Oct 25, 2016 at 1:34 PM, Dinko Srko─Ź <dinko.srkoc@gmail.com> wrote:
> On 25 October 2016 at 16:02, VG <vitorgg@gmail.com> wrote:
>> Hi there,
>>
>> why this does not work?
>>
>> class Example {
>>     @Delegate Date when
>> }
>>
>> def x = new Example(when: new Date())
>> x.next()  // fails
>>
>> I checked
>> http://docs.groovy-lang.org/latest/html/groovy-jdk/java/util/Date.html and
>> the next method is available there? Should not the method next be available
>> through @delegate?
>
> `next()` is not really a method on `java.util.Date`, but a Groovy's extension.
>
> `Date`'s methods are all there. E.g.
>
>     x.time // works

And just to interject the question the OP is probably going to ask:
Why should it matter whether it's an "extension" or not?  Is it
documented that the methods available on a Delegate exclude what
Groovy has added to the class?

Mime
View raw message