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

add a grep method on Object to perform a filter using a case expression (regex, range, class etc)

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.0-beta-4
    • None
    • None

    Description

      e.g. along these lines

      http://www.rubycentral.com/ref/ref_m_enumerable.html#grep

      In groovy we could do

      [1, 2, 3, 4, 5, 6, 7].grep(2..4)
      -> [2, 3, 4]

      or

      ["ab", "ac", "bc"].grep(~"a")
      -> ["ab", "ac"]

      or

      [1.1, 2, 3.4, 5.6, 7].grep(Integer)
      -> [2, 7]

      At the implementation we can find the items in the collection which return true for the 'isCase' method (used in switch statements)

      Attachments

        Activity

          People

            Unassigned Unassigned
            jstrachan James Strachan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: