Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1931

Map::find() should support two-parameter closures (i.e. key,value -> )

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1-beta-3
    • Component/s: None
    • Labels:
      None

      Description

      On 5/28/07, Chris vanBuskirk <Chris.vanBuskirk@vanderbilt.edu> wrote:
      >>> Sure, there is an easy workaround, but isn't lack of
      >>> support for two-param closures in find() a true-blue bug?
      >>
      >> I think we can do map.each

      { key, value -> ... }

      , so to be consistent,
      >> perhaps we should also allow find to work that way too.
      >>
      > Shall I file a bug/improvement request?

      GUILLAUME: "Yup: feature request or improvement."

      === HERE's WHAT I MEAN: ===

      def map = ['one':1, 'two':2, 'three':3]
      map.each

      {key,value -> if(key=='two') println "$key:$value"}

      println map.findAll

      {key,value -> key=='two'}
      println map.find { it.key=='two'}
      println map.find {key,value -> key=='two'}

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              vbuskirk Chris vanBuskirk
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: