Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: groovy-jdk
    • Labels:
      None

      Description

      Collection implements a method with the following signature:

      public Object findResult(Closure closure)

      It would be nice if a similar method existed for String.

      public Object findResult(Pattern pattern, Closure closure)

      The method find() almost performs the same function except that it converts the result to a string, even if it's null or a Boolean. Alternatively, the existing find() methods could be changed to return Object instead of String. Without this method, the matching string has to be saved into a temporary variable and then processed afterwards.

      Example:
      if (new File("file").text.findResult(~/VAR\s*=\s*(\S+)/)

      { it[1] != "VALUE1" }

      ) {
      // ...
      }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              balor123 Uri Moszkowicz
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: