[ 
https://issues.apache.org/jira/browse/GROOVY-5788?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles resolved GROOVY-5788.
---------------------------------
    Fix Version/s: 2.5.0
       Resolution: Fixed

"tap" added in Groovy 2.5

> Add inline() method to Object
> -----------------------------
>
>                 Key: GROOVY-5788
>                 URL: https://issues.apache.org/jira/browse/GROOVY-5788
>             Project: Groovy
>          Issue Type: New Feature
>          Components: groovy-jdk
>            Reporter: Uri Moszkowicz
>            Priority: Minor
>             Fix For: 2.5.0
>
>
> Deriving from discussion in GROOVY-5785, it would be nice if there were a way 
> to call methods inline which return undesired return values. In the other 
> issue, the example was calling removeAll() to find the difference between two 
> sets:
> def extra = set1.clone()
> extra.removeAll(set2)
> println extra.size()
> You could use Object#with() here:
> println(set1.clone().with { removeAll(set2); it }.size())
> The inline() method implies "return it" at the end of the closure:
> println(set1.clone().inline { removeAll(set2) }.size())
> It might even make sense to define a new operator rather than a method, 
> similar to the safe navigation operator:
> println(set1.clone()&.removeAll(set2).size())



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to