You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2023/07/13 19:58:00 UTC

[jira] [Closed] (GROOVY-5053) Support for two-parameter closures in collect{} find{} each{} and etc accepting "it" and its index

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

Eric Milles closed GROOVY-5053.
-------------------------------
    Resolution: Information Provided

> Support for two-parameter closures in collect{} find{} each{} and etc accepting "it" and its index
> --------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-5053
>                 URL: https://issues.apache.org/jira/browse/GROOVY-5053
>             Project: Groovy
>          Issue Type: Improvement
>          Components: groovy-jdk
>    Affects Versions: 1.8.2
>            Reporter: Nikita Y Volkov
>            Priority: Major
>
> This would be extremely useful, much more consistent and smarter than implementations like {{eachWithIndex}}. Whenever the user provides a two parameter closure to any of those {{Iterable}} extension methods, this would mean that the first parameter is the current item and the second is its index. If the closure has one parameter (or none), the current item gets passed. In all other cases it should throw an exception. A simple and very productive convention.
> This feature would be very easy to implement by checking the {{closure.parameterTypes.length}}. I know that 'cuz I have it implemented in my lib. I can provide a patch if this will help the feature to be implemented sooner.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)