Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
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
-
Number of attachments :
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
- relates to
-
GROOVY-5273
Provide contains as a DGM method for primitive arrays
-
Looks like this is going to be in the next release...
https://github.com/groovy/groovy-core/commit/db1733a7ed270c8193727c0764005856bfcf7919
Wish I'd checked the commits before starting work on a local version
You live and learn I guess