Groovy
  1. Groovy
  2. GROOVY-5263

New GDK method: Object[].contains()

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.5, 2.0-beta-2
    • Fix Version/s: 1.8.6, 2.0-beta-3
    • Component/s: groovy-jdk
    • Labels:
      None

      Description

      We treat arrays as Lists in may respects. There are methods from List that have been grafted unto arrays however there is no contains() method which would come in handy in scenarios like the following one

      if(!arrayOfObjects.contains(element)) {
          arrayOfObjects << elements
      }
      

      One way to do it currently is this

      if( !(element in arrayOfObjects) ) {
          arrayOfObjects << elements
      }
      

      Notice the additional () around the expression

        Issue Links

          Activity

          Mark Thomas made changes -
          Workflow jira [ 12971652 ] Default workflow, editable Closed status [ 12979474 ]
          Mark Thomas made changes -
          Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
          Mark Thomas made changes -
          Workflow jira [ 12734186 ] Default workflow, editable Closed status [ 12745936 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
          Paul King made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Paul King made changes -
          Resolution Fixed [ 1 ]
          Fix Version/s 2.0-beta-3 [ 18244 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 1.8.6 [ 18245 ]
          Paul King made changes -
          Assignee Paul King [ paulk ]
          Jochen Theodorou made changes -
          Field Original Value New Value
          Link This issue relates to GROOVY-5273 [ GROOVY-5273 ]
          Andres Almiray created issue -

            People

            • Assignee:
              Paul King
              Reporter:
              Andres Almiray
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development