groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcin Erdmann <marcin.erdm...@proxerd.pl>
Subject Re: Default Method for Groovy 3
Date Thu, 08 Dec 2016 17:50:57 GMT
That's great news. Not being able to use default interface methods,
especially when working with libraries using them in Java code, felt
limiting.

On Thu, 8 Dec 2016 at 17:40, Daniel Sun <realbluesun@hotmail.com> wrote:

> Hi all,
>
>
>
>          The new parser(Parrot) supports default method now. You can find
>
> the new feature at  the enhancedInterface branch of groovy-parser project
>
> <https://github.com/danielsun1106/groovy-parser/tree/enhancedInterface>  (
>
>
> https://github.com/danielsun1106/groovy-parser/commit/89f45ac86e7945ef81283697b6ed9018e997a045
>
> ). If no problem with the implementation, I'll merge it into the master
>
> later.
>
>
>
> *Here is an example:*
>
>
>
> interface Greetable {
>
>     String name();
>
>     default String hello() {
>
>         return 'hello'
>
>     }
>
> }
>
>
>
> class Person implements Greetable {
>
>     @Override
>
>     public String name() {
>
>         return 'Daniel'
>
>     }
>
> }
>
>
>
> def p = new Person()
>
> assert 'hello, Daniel' == "${p.hello()}, ${p.name()}"
>
>
>
>       *Another more complicated example can be found at:*
>
>
> https://github.com/danielsun1106/groovy-parser/blob/enhancedInterface/src/test/resources/core/DefaultMethod_02x.groovy
>
>
>
>
>
> Cheers,
>
> Daniel.Sun
>
>
>
>
>
>
>
>
>
> --
>
> View this message in context:
> http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154.html
>
> Sent from the Groovy Dev mailing list archive at Nabble.com.
>
>

Mime
View raw message