[ 
https://issues.apache.org/jira/browse/GROOVY-1724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15504766#comment-15504766
 ] 

Paul King commented on GROOVY-1724:
-----------------------------------

You could try this trick:
{code}
abstract class AbstractStuff {
    String reverse(String value) {
        new StringBuilder(value).reverse().toString()
    }
    abstract String concat(String one, String two)
}

Closure delegateToReverse
AbstractStuff stuff = { String one, String two -> delegateToReverse(one + two) }
delegateToReverse = { stuff.reverse(it) }
assert stuff.concat('1','2') == '21'
{code}

> Extend Map coercion to classes
> ------------------------------
>
>                 Key: GROOVY-1724
>                 URL: https://issues.apache.org/jira/browse/GROOVY-1724
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Guillaume Delcroix
>            Assignee: Jochen Theodorou
>             Fix For: 1.1-beta-3
>
>
> Currently, it is possible to define Map coercion to interfaces:
> [foo: {}, bar: {}] as SomeInterface
> The mechanism leverages Java proxies and invocation handlers.
> The mechanism should be enhanced to allow extending classes as well.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to