Package: java.lang

## Class Object[]

- - ### Methods Summary

    Methods
    Return type | Name and parameters
    --- | ---
    `boolean` | `any(Closure predicate)` Iterates over the contents of an Array, and checks whether a predicate is valid for at least one element.
    `List` | `chop(int chopSizes)` Chops the array into pieces, returning lists with sizes corresponding to the supplied chop sizes.
    `List` | `collate(int size)` Collates an array.
    `List` | `collate(int size, boolean keepRemainder)` Collates this array into sub-lists.
    `List` | `collate(int size, int step)` Collates an array into sub-lists.
    `List` | `collate(int size, int step, boolean keepRemainder)` Collates this array into into sub-lists.
    `List` | `collect(Closure transform)` Iterates through this Array transforming each item into a new value using the `transform` closure, returning a list of transformed values.
    `Collection` | `collect(Collection collector, Closure transform)` Iterates through this Array transforming each item into a new value using the `transform` closure and adding it to the supplied `collector`.
    `Map` | `collectEntries()` A variant of collectEntries using the identity closure as the transform.
    `Map` | `collectEntries(Closure transform)` Iterates through this array transforming each item using the `transform` closure and returning a map of the resulting transformed entries.
    `Map` | `collectEntries(Map collector)` A variant of collectEntries using the identity closure as the transform.
    `Map` | `collectEntries(Map collector, Closure transform)` Iterates through this array transforming each item using the `transform` closure and returning a map of the resulting transformed entries.
    `List` | `collectMany(Closure projection)` Projects each item from a source array to a collection and concatenates (flattens) the resulting collections into a single list.
    `Number` | `count(Closure closure)` Counts the number of occurrences which satisfy the given closure from inside this array.
    `Map` | `countBy(Closure closure)` Sorts all array members into groups determined by the supplied mapping closure and counts the group size.
    `Object[]` | `drop(int num)` Drops the given number of elements from the head of this array if they are available.
    `Object[]` | `dropRight(int num)` Drops the given number of elements from the tail of this array if they are available.
    `Object[]` | `dropWhile(Closure condition)` Create a suffix of the given array by dropping as many elements as possible from the front of the original array such that calling the given closure condition evaluates to true when passed each of the dropped elements.
    `Object[]` | `each(Closure closure)` Iterates through an array passing each array entry to the given closure.
    `Object[]` | `eachWithIndex(Closure closure)` Iterates through an array, passing each array element and the element's index (a counter starting at zero) to the given closure.
    `boolean` | `every(Closure predicate)` Used to determine if the given predicate closure is valid (i.e. returns `true` for all items in this Array).
    `Object` | `find(Closure condition)` Finds the first element in the array that matches the given closure condition.
    `Collection` | `findAll()` Finds the elements of the array matching the IDENTITY Closure (i.e. matching Groovy truth).
    `Collection` | `findAll(Closure condition)` Finds all elements of the array matching the given Closure condition.
    `int` | `findIndexOf(Closure condition)` Iterates over the elements of an Array and returns the index of the first item that satisfies the condition specified by the closure.
    `int` | `findIndexOf(int startIndex, Closure condition)` Iterates over the elements of an Array, starting from a specified startIndex, and returns the index of the first item that satisfies the condition specified by the closure.
    `List` | `findIndexValues(Closure condition)` Iterates over the elements of an Array and returns the index values of the items that match the condition specified in the closure.
    `List` | `findIndexValues(Number startIndex, Closure condition)` Iterates over the elements of an Array, starting from a specified startIndex, and returns the index values of the items that match the condition specified in the closure.
    `int` | `findLastIndexOf(Closure condition)` Iterates over the elements of an Array and returns the index of the last item that matches the condition specified in the closure.
    `int` | `findLastIndexOf(int startIndex, Closure condition)` Iterates over the elements of an Array, starting from a specified startIndex, and returns the index of the last item that matches the condition specified in the closure.
    `Object` | `findResult(Closure condition)` Iterates through the Array calling the given closure condition for each item but stopping once the first non-null result is found and returning that result.
    `Object` | `findResult(Object defaultResult, Closure condition)` Iterates through the Array calling the given closure condition for each item but stopping once the first non-null result is found and returning that result.
    `Collection` | `findResults(Closure filteringTransform)` Iterates through the Array transforming items using the supplied closure and collecting any non-null results.
    `Object` | `first()` Returns the first item from the array.
    `List` | `getAt(EmptyRange range)`
    `List` | `getAt(IntRange range)`
    `List` | `getAt(ObjectRange range)`
    `List` | `getAt(Range range)` Support the range subscript operator for an Array
    `List` | `getAt(Collection indices)` Select a List of items from an array using a Collection to identify the indices to be selected.
    `IntRange` | `getIndices()` Returns indices of the array.
    `Collection` | `grep()` Iterates over the array returning each element that matches using the IDENTITY Closure as a filter - effectively returning all elements which satisfy Groovy truth.
    `Collection` | `grep(Object filter)` Iterates over the array of items and returns a collection of items that match the given filter - calling the `Object#isCase(java.lang.Object)` method used by switch statements.
    `Map` | `groupBy(Closure closure)` Sorts all array members into groups determined by the supplied mapping closure.
    `Object` | `head()` Returns the first item from the Object array.
    `Object[]` | `init()` Returns the items from the Object array excluding the last item.
    `Object` | `inject(Closure closure)` Iterates through the given array as with inject(Object[],initialValue,closure), but using the first element of the array as the initialValue, and then iterating the remaining elements of the array.
    `Object` | `inject(Object initialValue, Closure closure)` Iterates through the given array, passing in the initial value to the closure along with the first item.
    `Iterator` | `iterator()` Attempts to create an Iterator for the given object by first converting it to a Collection.
    `Object` | `last()` Returns the last item from the array.
    `Object` | `max()` Adds max() method to Object arrays.
    `Object` | `max(Closure closure)` Selects the maximum value found from the Object array using the closure to determine the correct ordering.
    `Object` | `max(Comparator comparator)` Selects the maximum value found from the Object array using the given comparator.
    `Object` | `min()` Adds min() method to Object arrays.
    `Object` | `min(Closure closure)` Selects the minimum value found from the Object array using the closure to determine the correct ordering.
    `Object` | `min(Comparator comparator)` Selects the minimum value found from the Object array using the given comparator.
    `Object[]` | `minus(Iterable removeMe)` Create an array composed of the elements of the first array minus the elements of the given Iterable.
    `Object[]` | `minus(Object removeMe)` Create a new object array composed of the elements of the first array minus the element to remove.
    `Object[]` | `minus(Object[] removeMe)` Create an array composed of the elements of the first array minus the elements of the given array.
    `Object[]` | `plus(Iterable right)` Create an array containing elements from an original array plus those from an Iterable.
    `Object[]` | `plus(Object right)` Create an array containing elements from an original array plus an additional appended element.
    `Object[]` | `plus(Object[] right)` Create an array as a union of two arrays.
    `Object[]` | `plus(Collection right)` Create an array containing elements from an original array plus those from a Collection.
    `Object[]` | `reverse()` Creates a new array containing items which are the same as this array but in reverse order.
    `Object[]` | `reverse(boolean mutate)` Reverse the items in an array.
    `Object[]` | `reverseEach(Closure closure)` Iterate over each element of the array in the reverse order.
    `Object[]` | `sort()` Modifies this array so that its elements are in sorted order.
    `Object[]` | `sort(boolean mutate)` Sorts the given array into sorted order.
    `Object[]` | `sort(boolean mutate, Closure closure)` Modifies this array so that its elements are in sorted order using the Closure to determine the correct ordering.
    `Object[]` | `sort(boolean mutate, Comparator comparator)` Modifies this array so that its elements are in sorted order as determined by the given comparator.
    `Object[]` | `sort(Closure closure)` Sorts the elements from this array into a newly created array using the Closure to determine the correct ordering.
    `Object[]` | `sort(Comparator comparator)` Sorts the given array into sorted order using the given comparator.
    `Collection` | `split(Closure closure)` Splits all items into two collections based on the closure condition.
    `Stream` | `stream()` Returns a sequential Stream with the specified array as its source.
    `Object` | `sum(Closure closure)` Sums the result of apply a closure to each item of an array.
    `Object` | `sum(Object initialValue, Closure closure)` Sums the result of applying a closure to each item of an array to some initial value.
    `Object[]` | `swap(int i, int j)` Swaps two elements at the specified positions.
    `Object[]` | `tail()` Returns the items from the array excluding the first item.
    `Object[]` | `take(int num)` Returns the first `num` elements from the head of this array.
    `Object[]` | `takeRight(int num)` Returns the last `num` elements from the tail of this array.
    `Object[]` | `takeWhile(Closure condition)` Returns the longest prefix of this array where each element passed to the given closure evaluates to true.
    `List` | `toList()` Allows conversion of arrays into a mutable List.
    `Object[]` | `toSorted()` Returns a sorted version of the given array using the supplied comparator.
    `Object[]` | `toSorted(Closure condition)` Sorts the elements from this array into a newly created array using the Closure to determine the correct ordering.
    `Object[]` | `toSorted(Comparator comparator)` Returns a sorted version of the given array using the supplied comparator to determine the resulting order.
    `Object[]` | `toUnique()` Returns a new Array containing the items from the original Array but with duplicates removed using the natural ordering of the items in the array.
    `Object[]` | `toUnique(Closure condition)` Returns a new Array containing the items from the original Array but with duplicates removed with the supplied comparator determining which items are unique.
    `Object[]` | `toUnique(Comparator comparator)` Returns a new Array containing the items from the original Array but with duplicates removed with the supplied comparator determining which items are unique.

- - ### Methods Detail

    - #### public boolean any(Closure predicate)

      Iterates over the contents of an Array, and checks whether a predicate is valid for at least one element.

      Parameters:
        `predicate` - the closure predicate used for matching
      Returns:
        true if any iteration for the object matches the closure predicate
      Since:
        2.5.0

    - #### public List chop(int chopSizes)

      Chops the array into pieces, returning lists with sizes corresponding to the supplied chop sizes. If the array isn't large enough, truncated (possibly empty) pieces are returned. Using a chop size of -1 will cause that piece to contain all remaining items from the array.

      Parameters:
        `chopSizes` - the sizes for the returned pieces
      Returns:
        a list of lists chopping the original array elements into pieces determined by chopSizes
      Since:
        2.5.2
      See Also:
        Object[]#collate(int)

    - #### public List collate(int size)

      Collates an array.

      Parameters:
        `size` - the length of each sub-list in the returned list
      Returns:
        a List containing the array values collated into sub-lists
      Since:
        2.5.0
      See Also:
        Iterable#collate(int)

    - #### public List collate(int size, boolean keepRemainder)

      Collates this array into sub-lists.

      Parameters:
        `size` - the length of each sub-list in the returned list
        `keepRemainder` - if true, any remaining elements are returned as sub-lists. Otherwise they are discarded
      Returns:
        a List containing the array elements collated into sub-lists
      Since:
        2.5.0
      See Also:
        Iterable#collate(int, boolean)

    - #### public List collate(int size, int step)

      Collates an array into sub-lists.

      Parameters:
        `size` - the length of each sub-list in the returned list
        `step` - the number of elements to step through for each sub-list
      Returns:
        a List containing the array elements collated into sub-lists
      Since:
        2.5.0
      See Also:
        Iterable#collate(int, int)

    - #### public List collate(int size, int step, boolean keepRemainder)

      Collates this array into into sub-lists.

      Parameters:
        `size` - the length of each sub-list in the returned list
        `step` - the number of elements to step through for each sub-list
        `keepRemainder` - if true, any remaining elements are returned as sub-lists. Otherwise they are discarded
      Returns:
        a List containing the array elements collated into sub-lists
      Since:
        2.5.0

    - #### public List collect(Closure transform)

      Iterates through this Array transforming each item into a new value using the `transform` closure, returning a list of transformed values.

      Parameters:
        `transform` - the closure used to transform each item of the Array
      Returns:
        a List of the transformed values
      Since:
        2.5.0

    - #### public Collection collect(Collection collector, Closure transform)

      Iterates through this Array transforming each item into a new value using the `transform` closure and adding it to the supplied `collector`.

          Integer[] nums = [1,2,3]
          List answer = []
          nums.collect(answer) { it * 2 }
          assert [2,4,6] == answer

      Parameters:
        `collector` - the Collection to which the transformed values are added
        `transform` - the closure used to transform each item
      Returns:
        the collector with all transformed values added to it
      Since:
        2.5.0

    - #### public Map collectEntries()

      A variant of collectEntries using the identity closure as the transform.

      Returns:
        the collector with all transformed values added to it
      Since:
        1.8.5
      See Also:
        Object[]#collectEntries(Closure)

    - #### public Map collectEntries(Closure transform)

      Iterates through this array transforming each item using the `transform` closure and returning a map of the resulting transformed entries.

          def letters = "abc"
          def nums = [0, 1, 2] as Integer[]
          // collect letters with index using list style
          assert nums.collectEntries { index -> [index, letters[index]] } == [0:'a', 1:'b', 2:'c']
          // collect letters with index using map style
          assert nums.collectEntries { index -> [(index): letters[index]] } == [0:'a', 1:'b', 2:'c']

      Note: When using the list-style of result, the behavior is '`def (key, value) = listResultFromClosure`'. While we strongly discourage using a list of size other than 2, Groovy's normal semantics apply in this case; throwing away elements after the second one and using null for the key or value for the case of a shortened list.
      Parameters:
        `transform` - the closure used for transforming, which has an item from self as the parameter and should return a Map.Entry, a Map or a two-element list containing the resulting key and value
      Returns:
        a Map of the transformed entries
      Since:
        1.7.9
      See Also:
        Iterable#collectEntries(Map, Closure)

    - #### public Map collectEntries(Map collector)

      A variant of collectEntries using the identity closure as the transform.

      Parameters:
        `collector` - the Map into which the transformed entries are put
      Returns:
        the collector with all transformed values added to it
      Since:
        1.8.5
      See Also:
        Object[]#collectEntries(Map, Closure)

    - #### public Map collectEntries(Map collector, Closure transform)

      Iterates through this array transforming each item using the `transform` closure and returning a map of the resulting transformed entries.

          def letters = "abc"
          def nums = [0, 1, 2] as Integer[]
          // collect letters with index
          assert nums.collectEntries( [:] ) { index -> [index, letters[index]] } == [0:'a', 1:'b', 2:'c']
          assert nums.collectEntries( [4:'d'] ) { index ->
              [(index+1): letters[index]] } == [1:'a', 2:'b', 3:'c', 4:'d']

      Note: When using the list-style of result, the behavior is '`def (key, value) = listResultFromClosure`'. While we strongly discourage using a list of size other than 2, Groovy's normal semantics apply in this case; throwing away elements after the second one and using null for the key or value for the case of a shortened list. If your collector Map doesn't support null keys or values, you might get a runtime error, e.g. NullPointerException or IllegalArgumentException.
      Parameters:
        `collector` - the Map into which the transformed entries are put
        `transform` - the closure used for transforming, which has an item from self as the parameter and should return a Map.Entry, a Map or a two-element list containing the resulting key and value
      Returns:
        the collector with all transformed values added to it
      Since:
        1.7.9
      See Also:
        Map#collect(Collection, Closure)

    - #### public List collectMany(Closure projection)

      Projects each item from a source array to a collection and concatenates (flattens) the resulting collections into a single list.

          def nums = [1, 2, 3, 4, 5, 6] as Object[]
          def squaresAndCubesOfEvens = nums.collectMany{ it % 2 ? [] : [it**2, it**3] }
          assert squaresAndCubesOfEvens == [4, 8, 16, 64, 36, 216]

      Parameters:
        `projection` - a projecting Closure returning a collection of items
      Returns:
        a list created from the projected collections concatenated (flattened) together
      Since:
        1.8.1
      See Also:
        Object[]#sum(groovy.lang.Closure)

    - #### public Number count(Closure closure)

      Counts the number of occurrences which satisfy the given closure from inside this array.

      Parameters:
        `closure` - a closure condition
      Returns:
        the number of occurrences
      Since:
        1.8.0

    - #### public Map countBy(Closure closure)

      Sorts all array members into groups determined by the supplied mapping closure and counts the group size. The closure should return the key that each item should be grouped by. The returned Map will have an entry for each distinct key returned from the closure, with each value being the frequency of items occurring for that group.

      Example usage:

          assert ([1,2,2,2,3] as Object[]).countBy{ it % 2 } == [1:2, 0:3]

      Parameters:
        `closure` - a closure mapping items to the frequency keys
      Returns:
        a new Map grouped by keys with frequency counts
      Since:
        1.8.0
      See Also:
        Collection#countBy(Closure)

    - #### public Object[] drop(int num)

      Drops the given number of elements from the head of this array if they are available.

          String[] strings = [ 'a', 'b', 'c' ]
          assert strings.drop( 0 ) == [ 'a', 'b', 'c' ] as String[]
          assert strings.drop( 2 ) == [ 'c' ] as String[]
          assert strings.drop( 5 ) == [] as String[]

      Parameters:
        `num` - the number of elements to drop from this array
      Returns:
        an array consisting of all elements of this array except the first `num` ones, or else the empty array, if this array has less than `num` elements.
      Since:
        1.8.1

    - #### public Object[] dropRight(int num)

      Drops the given number of elements from the tail of this array if they are available.

          String[] strings = [ 'a', 'b', 'c' ]
          assert strings.dropRight( 0 ) == [ 'a', 'b', 'c' ] as String[]
          assert strings.dropRight( 2 ) == [ 'a' ] as String[]
          assert strings.dropRight( 5 ) == [] as String[]

      Parameters:
        `num` - the number of elements to drop from this array
      Returns:
        an array consisting of all elements of this array except the last `num` ones, or else the empty array, if this array has less than `num` elements.
      Since:
        2.4.0

    - #### public Object[] dropWhile(Closure condition)

      Create a suffix of the given array by dropping as many elements as possible from the front of the original array such that calling the given closure condition evaluates to true when passed each of the dropped elements.

          def nums = [ 1, 3, 2 ] as Integer[]
          assert nums.dropWhile{ it <= 3 } == [ ] as Integer[]
          assert nums.dropWhile{ it < 3 } == [ 3, 2 ] as Integer[]
          assert nums.dropWhile{ it != 2 } == [ 2 ] as Integer[]
          assert nums.dropWhile{ it == 0 } == [ 1, 3, 2 ] as Integer[]

      Parameters:
        `condition` - the closure that must evaluate to true to continue dropping elements
      Returns:
        the shortest suffix of the given array such that the given closure condition evaluates to true for each element dropped from the front of the array
      Since:
        1.8.7

    - #### public Object[] each(Closure closure)

      Iterates through an array passing each array entry to the given closure.

          String[] letters = ['a', 'b', 'c']
          String result = ''
          letters.each{ result += it }
          assert result == 'abc'

      Parameters:
        `closure` - the closure applied on each array entry
      Returns:
        the self array
      Since:
        2.5.0

    - #### public Object[] eachWithIndex(Closure closure)

      Iterates through an array, passing each array element and the element's index (a counter starting at zero) to the given closure.

          String[] letters = ['a', 'b', 'c']
          String result = ''
          letters.eachWithIndex{ letter, index -> result += "$index:$letter" }
          assert result == '0:a1:b2:c'

      Parameters:
        `closure` - a Closure to operate on each array entry
      Returns:
        the self array
      Since:
        2.5.0

    - #### public boolean every(Closure predicate)

      Used to determine if the given predicate closure is valid (i.e. returns `true` for all items in this Array).

      Parameters:
        `predicate` - the closure predicate used for matching
      Returns:
        true if every element of the Array matches the closure predicate
      Since:
        2.5.0

    - #### public Object find(Closure condition)

      Finds the first element in the array that matches the given closure condition. Example:

          def list = [1,2,3] as Integer[]
          assert 2 == list.find { it > 1 }
          assert null == list.find { it > 5 }

      Parameters:
        `condition` - a closure condition
      Returns:
        the first element from the array that matches the condition or null if no element matches
      Since:
        2.0

    - #### public Collection findAll()

      Finds the elements of the array matching the IDENTITY Closure (i.e. matching Groovy truth).

      Example:

          def items = [1, 2, 0, false, true, '', 'foo', [], [4, 5], null] as Object[]
          assert items.findAll() == [1, 2, true, 'foo', [4, 5]]

      Returns:
        a collection of the elements found
      Since:
        2.0
      See Also:
        Closure#IDENTITY

    - #### public Collection findAll(Closure condition)

      Finds all elements of the array matching the given Closure condition.

          def items = [1,2,3,4] as Integer[]
          assert [2,4] == items.findAll { it % 2 == 0 }

      Parameters:
        `condition` - a closure condition
      Returns:
        a list of matching values
      Since:
        2.0

    - #### public int findIndexOf(Closure condition)

      Iterates over the elements of an Array and returns the index of the first item that satisfies the condition specified by the closure.

      Parameters:
        `condition` - the matching condition
      Returns:
        an integer that is the index of the first matched object or -1 if no match was found
      Since:
        2.5.0

    - #### public int findIndexOf(int startIndex, Closure condition)

      Iterates over the elements of an Array, starting from a specified startIndex, and returns the index of the first item that satisfies the condition specified by the closure.

      Parameters:
        `startIndex` - start matching from this index
        `condition` - the matching condition
      Returns:
        an integer that is the index of the first matched object or -1 if no match was found
      Since:
        2.5.0

    - #### public List findIndexValues(Closure condition)

      Iterates over the elements of an Array and returns the index values of the items that match the condition specified in the closure.

      Parameters:
        `condition` - the matching condition
      Returns:
        a list of numbers corresponding to the index values of all matched objects
      Since:
        2.5.0

    - #### public List findIndexValues(Number startIndex, Closure condition)

      Iterates over the elements of an Array, starting from a specified startIndex, and returns the index values of the items that match the condition specified in the closure.

      Parameters:
        `startIndex` - start matching from this index
        `condition` - the matching condition
      Returns:
        a list of numbers corresponding to the index values of all matched objects
      Since:
        2.5.0

    - #### public int findLastIndexOf(Closure condition)

      Iterates over the elements of an Array and returns the index of the last item that matches the condition specified in the closure.

      Parameters:
        `condition` - the matching condition
      Returns:
        an integer that is the index of the last matched object or -1 if no match was found
      Since:
        2.5.0

    - #### public int findLastIndexOf(int startIndex, Closure condition)

      Iterates over the elements of an Array, starting from a specified startIndex, and returns the index of the last item that matches the condition specified in the closure.

      Parameters:
        `startIndex` - start matching from this index
        `condition` - the matching condition
      Returns:
        an integer that is the index of the last matched object or -1 if no match was found
      Since:
        2.5.0

    - #### public Object findResult(Closure condition)

      Iterates through the Array calling the given closure condition for each item but stopping once the first non-null result is found and returning that result. If all results are null, null is returned.

      Parameters:
        `condition` - a closure that returns a non-null value to indicate that processing should stop and the value should be returned
      Returns:
        the first non-null result from calling the closure, or null
      Since:
        2.5.0

    - #### public Object findResult(Object defaultResult, Closure condition)

      Iterates through the Array calling the given closure condition for each item but stopping once the first non-null result is found and returning that result. If all are null, the defaultResult is returned.

      Parameters:
        `defaultResult` - an Object that should be returned if all closure results are null
        `condition` - a closure that returns a non-null value to indicate that processing should stop and the value should be returned
      Returns:
        the first non-null result from calling the closure, or the defaultValue
      Since:
        2.5.0

    - #### public Collection findResults(Closure filteringTransform)

      Iterates through the Array transforming items using the supplied closure and collecting any non-null results.

      Parameters:
        `filteringTransform` - a Closure that should return either a non-null transformed value or null for items which should be discarded
      Returns:
        the list of non-null transformed values
      Since:
        2.5.0

    - #### public Object first()

      Returns the first item from the array.

          def array = [3, 4, 2].toArray()
          assert array.first() == 3

      Returns:
        the first item from the array
      Since:
        1.7.3

    - #### public List getAt(EmptyRange range)

      Parameters:
        `range` - an EmptyRange
      Returns:
        an empty Range
      Since:
        1.5.0

    - #### public List getAt(IntRange range)

      Parameters:
        `range` - an IntRange
      Returns:
        a range of a list from the range's from index up to but not including the range's to value
      Since:
        1.0

    - #### public List getAt(ObjectRange range)

      Parameters:
        `range` - an ObjectRange
      Returns:
        a range of a list from the range's from index up to but not including the range's to value
      Since:
        1.0

    - #### public List getAt(Range range)

      Support the range subscript operator for an Array

      Parameters:
        `range` - a Range
      Returns:
        a range of a list from the range's from index up to but not including the range's to value
      Since:
        1.0

    - #### public List getAt(Collection indices)

      Select a List of items from an array using a Collection to identify the indices to be selected.

      Parameters:
        `indices` - a Collection of indices
      Returns:
        a new list of the values at the given indices
      Since:
        1.0

    - #### public IntRange getIndices()

      Returns indices of the array.

      Example:

          String[] letters = ['a', 'b', 'c', 'd']
          assert 0..<4 == letters.indices

      Returns:
        an index range
      Since:
        2.4.0

    - #### public Collection grep()

      Iterates over the array returning each element that matches using the IDENTITY Closure as a filter - effectively returning all elements which satisfy Groovy truth.

      Example:

          def items = [1, 2, 0, false, true, '', 'foo', [], [4, 5], null] as Object[]
          assert items.grep() == [1, 2, true, 'foo', [4, 5]]

      Returns:
        a collection of elements which satisfy Groovy truth
      Since:
        2.0
      See Also:
        Closure#IDENTITY

    - #### public Collection grep(Object filter)

      Iterates over the array of items and returns a collection of items that match the given filter - calling the `Object#isCase(java.lang.Object)` method used by switch statements. This method can be used with different kinds of filters like regular expressions, classes, ranges etc. Example:

          def items = ['a', 'b', 'aa', 'bc', 3, 4.5] as Object[]
          assert items.grep( ~/a+/ )  == ['a', 'aa']
          assert items.grep( ~/../ )  == ['aa', 'bc']
          assert items.grep( Number ) == [ 3, 4.5 ]
          assert items.grep{ it.toString().size() == 1 } == [ 'a', 'b', 3 ]

      Parameters:
        `filter` - the filter to perform on each element of the array (using the Object#isCase(java.lang.Object) method)
      Returns:
        a collection of objects which match the filter
      Since:
        2.0

    - #### public Map groupBy(Closure closure)

      Sorts all array members into groups determined by the supplied mapping closure. The closure should return the key that this item should be grouped by. The returned LinkedHashMap will have an entry for each distinct key returned from the closure, with each value being a list of items for that group.

      Example usage:

          Integer[] items = [1,2,3,4,5,6]
          assert [0:[2,4,6], 1:[1,3,5]] == items.groupBy { it % 2 }

      Parameters:
        `closure` - a closure mapping entries on keys
      Returns:
        a new Map grouped by keys
      Since:
        2.2.0
      See Also:
        Iterable#groupBy(Closure)

    - #### public Object head()

      Returns the first item from the Object array.

          def array = [3, 4, 2].toArray()
          assert array.head() == 3

      Returns:
        the first item from the Object array
      Since:
        1.7.3

    - #### public Object[] init()

      Returns the items from the Object array excluding the last item.

              String[] strings = ["a", "b", "c"]
              def result = strings.init()
              assert result.length == 2
              assert strings.class.componentType == String

      Returns:
        an array without its last element
      Since:
        2.4.0

    - #### public Object inject(Closure closure)

      Iterates through the given array as with inject(Object[],initialValue,closure), but using the first element of the array as the initialValue, and then iterating the remaining elements of the array.

      Parameters:
        `closure` - a closure
      Returns:
        the result of the last closure call
      Since:
        1.8.7
      See Also:
        Object[]#inject(Object, Closure)

    - #### public Object inject(Object initialValue, Closure closure)

      Iterates through the given array, passing in the initial value to the closure along with the first item. The result is passed back (injected) into the closure along with the second item. The new result is injected back into the closure along with the third item and so on until all elements of the array have been used. Also known as foldLeft in functional parlance.

      Parameters:
        `initialValue` - some initial value
        `closure` - a closure
      Returns:
        the result of the last closure call
      Since:
        1.5.0
      See Also:
        Collection#inject(Object, Closure)

    - #### public Iterator iterator()

      Attempts to create an Iterator for the given object by first converting it to a Collection.

      Returns:
        an Iterator for the given Array.
      Since:
        1.6.4
      See Also:
        DefaultTypeTransformation#asCollection(java.lang.Object[])

    - #### public Object last()

      Returns the last item from the array.

          def array = [3, 4, 2].toArray()
          assert array.last() == 2

      Returns:
        the last item from the array
      Since:
        1.7.3

    - #### public Object max()

      Adds max() method to Object arrays.

      Returns:
        the maximum value
      Since:
        1.5.5
      See Also:
        Collection#max()

    - #### public Object max(Closure closure)

      Selects the maximum value found from the Object array using the closure to determine the correct ordering.

      If the closure has two parameters it is used like a traditional Comparator. I.e. it should compare its two parameters for order, returning a negative integer, zero, or a positive integer when the first parameter is less than, equal to, or greater than the second respectively. Otherwise, the Closure is assumed to take a single parameter and return a Comparable (typically an Integer) which is then used for further comparison.

      Parameters:
        `closure` - a Closure used to determine the correct ordering
      Returns:
        the maximum value
      Since:
        1.5.5
      See Also:
        Collection#max(groovy.lang.Closure)

    - #### public Object max(Comparator comparator)

      Selects the maximum value found from the Object array using the given comparator.

      Parameters:
        `comparator` - a Comparator
      Returns:
        the maximum value
      Since:
        1.5.5

    - #### public Object min()

      Adds min() method to Object arrays.

      Returns:
        the minimum value
      Since:
        1.5.5
      See Also:
        Collection#min()

    - #### public Object min(Closure closure)

      Selects the minimum value found from the Object array using the closure to determine the correct ordering.

      If the closure has two parameters it is used like a traditional Comparator. I.e. it should compare its two parameters for order, returning a negative integer, zero, or a positive integer when the first parameter is less than, equal to, or greater than the second respectively. Otherwise, the Closure is assumed to take a single parameter and return a Comparable (typically an Integer) which is then used for further comparison.

      Parameters:
        `closure` - a Closure used to determine the correct ordering
      Returns:
        the minimum value
      Since:
        1.5.5
      See Also:
        Collection#min(groovy.lang.Closure)

    - #### public Object min(Comparator comparator)

      Selects the minimum value found from the Object array using the given comparator.

      Parameters:
        `comparator` - a Comparator
      Returns:
        the minimum value
      Since:
        1.5.5
      See Also:
        Collection#min(java.util.Comparator)

    - #### public Object[] minus(Iterable removeMe)

      Create an array composed of the elements of the first array minus the elements of the given Iterable.

      Parameters:
        `removeMe` - a Collection of elements to remove
      Returns:
        an array with the supplied elements removed
      Since:
        1.5.5

    - #### public Object[] minus(Object removeMe)

      Create a new object array composed of the elements of the first array minus the element to remove.

      Parameters:
        `removeMe` - an element to remove from the array
      Returns:
        a new array with the operand removed
      Since:
        1.5.5

    - #### public Object[] minus(Object[] removeMe)

      Create an array composed of the elements of the first array minus the elements of the given array.

      Parameters:
        `removeMe` - an array of elements to remove
      Returns:
        an array with the supplied elements removed
      Since:
        1.5.5

    - #### public Object[] plus(Iterable right)

      Create an array containing elements from an original array plus those from an Iterable.

          class AbcIterable implements Iterable {
              Iterator iterator() { "abc".iterator() }
          }
          String[] letters = ['x', 'y', 'z']
          def result = letters + new AbcIterable()
          assert result == ['x', 'y', 'z', 'a', 'b', 'c'] as String[]
          assert result.class.array

      Parameters:
        `right` - an Iterable to be appended
      Returns:
        A new array containing elements from left with those from right appended.
      Since:
        1.8.7

    - #### public Object[] plus(Object right)

      Create an array containing elements from an original array plus an additional appended element.

          Integer[] a = [1, 2, 3]
          Integer[] result = a + 4
          assert result == [1, 2, 3, 4] as Integer[]

      Parameters:
        `right` - the value to append
      Returns:
        A new array containing left with right appended to it.
      Since:
        1.8.7

    - #### public Object[] plus(Object[] right)

      Create an array as a union of two arrays.

          Integer[] a = [1, 2, 3]
          Integer[] b = [4, 5, 6]
          assert a + b == [1, 2, 3, 4, 5, 6] as Integer[]

      Parameters:
        `right` - the right Array
      Returns:
        A new array containing right appended to left.
      Since:
        1.8.7

    - #### public Object[] plus(Collection right)

      Create an array containing elements from an original array plus those from a Collection.

          Integer[] a = [1, 2, 3]
          def additions = [7, 8]
          assert a + additions == [1, 2, 3, 7, 8] as Integer[]

      Parameters:
        `right` - a Collection to be appended
      Returns:
        A new array containing left with right appended to it.
      Since:
        1.8.7

    - #### public Object[] reverse()

      Creates a new array containing items which are the same as this array but in reverse order.

      Returns:
        an array containing the reversed items
      Since:
        1.5.5
      See Also:
        Object[]#reverse(boolean)

    - #### public Object[] reverse(boolean mutate)

      Reverse the items in an array. If mutate is true, the original array is modified in place and returned. Otherwise, a new array containing the reversed items is produced.

      Parameters:
        `mutate` - true if the array itself should be reversed in place and returned, false if a new array should be created
      Returns:
        an array containing the reversed items
      Since:
        1.8.1

    - #### public Object[] reverseEach(Closure closure)

      Iterate over each element of the array in the reverse order.

      Parameters:
        `closure` - a closure to which each item is passed
      Returns:
        the original array
      Since:
        1.5.2

    - #### public Object[] sort()

      Modifies this array so that its elements are in sorted order. The array items are assumed to be comparable.

      Returns:
        the sorted array
      Since:
        1.5.5

    - #### public Object[] sort(boolean mutate)

      Sorts the given array into sorted order. The array items are assumed to be comparable. If mutate is true, the array is sorted in place and returned. Otherwise, a new sorted array is returned and the original array remains unchanged.

          def orig = ["hello","hi","Hey"] as String[]
          def sorted = orig.sort(false)
          assert orig == ["hello","hi","Hey"] as String[]
          assert sorted == ["Hey","hello","hi"] as String[]
          orig.sort(true)
          assert orig == ["Hey","hello","hi"] as String[]

      Parameters:
        `mutate` - false will always cause a new array to be created, true will mutate the array in place
      Returns:
        the sorted array
      Since:
        1.8.1

    - #### public Object[] sort(boolean mutate, Closure closure)

      Modifies this array so that its elements are in sorted order using the Closure to determine the correct ordering. If mutate is false, a new array is returned and the original array remains unchanged. Otherwise, the original array is sorted in place and returned.

      If the closure has two parameters it is used like a traditional Comparator. I.e. it should compare its two parameters for order, returning a negative integer, zero, or a positive integer when the first parameter is less than, equal to, or greater than the second respectively. Otherwise, the Closure is assumed to take a single parameter and return a Comparable (typically an Integer) which is then used for further comparison.

          def orig = ["hello","hi","Hey"] as String[]
          def sorted = orig.sort(false) { it.size() }
          assert orig == ["hello","hi","Hey"] as String[]
          assert sorted == ["hi","Hey","hello"] as String[]
          orig.sort(true) { it.size() }
          assert orig == ["hi","Hey","hello"] as String[]

      Parameters:
        `mutate` - false will always cause a new array to be created, true will mutate arrays in place
        `closure` - a Closure used to determine the correct ordering
      Returns:
        the sorted array
      Since:
        1.8.1

    - #### public Object[] sort(boolean mutate, Comparator comparator)

      Modifies this array so that its elements are in sorted order as determined by the given comparator. If mutate is true, the array is sorted in place and returned. Otherwise, a new sorted array is returned and the original array remains unchanged.

          def orig = ["hello","hi","Hey"] as String[]
          def sorted = orig.sort(false, String.CASE_INSENSITIVE_ORDER)
          assert orig == ["hello","hi","Hey"] as String[]
          assert sorted == ["hello","Hey","hi"] as String[]
          orig.sort(true, String.CASE_INSENSITIVE_ORDER)
          assert orig == ["hello","Hey","hi"] as String[]

      Parameters:
        `mutate` - false will always cause a new array to be created, true will mutate arrays in place
        `comparator` - a Comparator used for the comparison
      Returns:
        a sorted array
      Since:
        1.8.1

    - #### public Object[] sort(Closure closure)

      Sorts the elements from this array into a newly created array using the Closure to determine the correct ordering.

      If the closure has two parameters it is used like a traditional Comparator. I.e. it should compare its two parameters for order, returning a negative integer, zero, or a positive integer when the first parameter is less than, equal to, or greater than the second respectively. Otherwise, the Closure is assumed to take a single parameter and return a Comparable (typically an Integer) which is then used for further comparison.

      Parameters:
        `closure` - a Closure used to determine the correct ordering
      Returns:
        the sorted array
      Since:
        1.5.5

    - #### public Object[] sort(Comparator comparator)

      Sorts the given array into sorted order using the given comparator.

      Parameters:
        `comparator` - a Comparator used for the comparison
      Returns:
        the sorted array
      Since:
        1.5.5

    - #### public Collection split(Closure closure)

      Splits all items into two collections based on the closure condition. The first list contains all items which match the closure expression. The second list all those that don't.

      Parameters:
        `closure` - a closure condition
      Returns:
        a List whose first item is the accepted values and whose second item is the rejected values
      Since:
        2.5.0

    - #### public Stream stream()

      Returns a sequential Stream with the specified array as its source.

      Returns:
        a `Stream` for the array

    - #### public Object sum(Closure closure)

      Sums the result of apply a closure to each item of an array. `array.sum(closure)` is equivalent to: `array.collect(closure).sum()`.

      Parameters:
        `closure` - a single parameter closure that returns a numeric value.
      Returns:
        The sum of the values returned by applying the closure to each item of the array.
      Since:
        1.7.1

    - #### public Object sum(Object initialValue, Closure closure)

      Sums the result of applying a closure to each item of an array to some initial value. `array.sum(initVal, closure)` is equivalent to: `array.collect(closure).sum(initVal)`.

      Parameters:
        `closure` - a single parameter closure that returns a numeric value.
        `initialValue` - the closure results will be summed to this initial value
      Returns:
        The sum of the values returned by applying the closure to each item of the array.
      Since:
        1.7.1

    - #### public Object[] swap(int i, int j)

      Swaps two elements at the specified positions.

      Example:

          assert (["a", "c", "b", "d"] as String[]) == (["a", "b", "c", "d"] as String[]).swap(1, 2)

      Parameters:
        `i` - a position
        `j` - a position
      Returns:
        self
      Since:
        2.4.0

    - #### public Object[] tail()

      Returns the items from the array excluding the first item.

          String[] strings = ["a", "b", "c"]
          def result = strings.tail()
          assert result.class.componentType == String
          String[] expected = ["b", "c"]
          assert result == expected

      Returns:
        an array without its first element
      Since:
        1.7.3

    - #### public Object[] take(int num)

      Returns the first `num` elements from the head of this array.

          String[] strings = [ 'a', 'b', 'c' ]
          assert strings.take( 0 ) == [] as String[]
          assert strings.take( 2 ) == [ 'a', 'b' ] as String[]
          assert strings.take( 5 ) == [ 'a', 'b', 'c' ] as String[]

      Parameters:
        `num` - the number of elements to take from this array
      Returns:
        an array consisting of the first `num` elements of this array, or else the whole array if it has less then `num` elements.
      Since:
        1.8.1

    - #### public Object[] takeRight(int num)

      Returns the last `num` elements from the tail of this array.

          String[] strings = [ 'a', 'b', 'c' ]
          assert strings.takeRight( 0 ) == [] as String[]
          assert strings.takeRight( 2 ) == [ 'b', 'c' ] as String[]
          assert strings.takeRight( 5 ) == [ 'a', 'b', 'c' ] as String[]

      Parameters:
        `num` - the number of elements to take from this array
      Returns:
        an array consisting of the last `num` elements of this array, or else the whole array if it has less then `num` elements.
      Since:
        2.4.0

    - #### public Object[] takeWhile(Closure condition)

      Returns the longest prefix of this array where each element passed to the given closure evaluates to true.

          def nums = [ 1, 3, 2 ] as Integer[]
          assert nums.takeWhile{ it < 1 } == [] as Integer[]
          assert nums.takeWhile{ it < 3 } == [ 1 ] as Integer[]
          assert nums.takeWhile{ it < 4 } == [ 1, 3, 2 ] as Integer[]

      Parameters:
        `condition` - the closure that must evaluate to true to continue taking elements
      Returns:
        a prefix of the given array where each element passed to the given closure evaluates to true
      Since:
        1.8.7

    - #### public List toList()

      Allows conversion of arrays into a mutable List.

      Returns:
        the array as a List
      Since:
        1.0

    - #### public Object[] toSorted()

      Returns a sorted version of the given array using the supplied comparator.

      Returns:
        the sorted array
      Since:
        2.4.0
      See Also:
        Object[]#toSorted(Comparator)

    - #### public Object[] toSorted(Closure condition)

      Sorts the elements from this array into a newly created array using the Closure to determine the correct ordering.

      If the closure has two parameters it is used like a traditional Comparator. I.e. it should compare its two parameters for order, returning a negative integer, zero, or a positive integer when the first parameter is less than, equal to, or greater than the second respectively. Otherwise, the Closure is assumed to take a single parameter and return a Comparable (typically an Integer) which is then used for further comparison.

      Parameters:
        `condition` - a Closure used to determine the correct ordering
      Returns:
        a sorted array
      Since:
        2.4.0
      See Also:
        Object[]#toSorted(Comparator)

    - #### public Object[] toSorted(Comparator comparator)

      Returns a sorted version of the given array using the supplied comparator to determine the resulting order.

          def sumDigitsComparator = [compare: { num1, num2 -> num1.toString().toList()*.toInteger().sum() <=> num2.toString().toList()*.toInteger().sum() }] as Comparator
          Integer[] nums = [9, 44, 222, 7000]
          def result = nums.toSorted(sumDigitsComparator)
          assert result instanceof Integer[]
          assert result == [222, 7000, 44, 9]

      Parameters:
        `comparator` - a Comparator used for the comparison
      Returns:
        the sorted array
      Since:
        2.4.0

    - #### public Object[] toUnique()

      Returns a new Array containing the items from the original Array but with duplicates removed using the natural ordering of the items in the array.

          String[] letters = ['c', 'a', 't', 's', 'a', 't', 'h', 'a', 't']
          String[] expected = ['c', 'a', 't', 's', 'h']
          def result = letters.toUnique()
          assert result == expected
          assert result.class.componentType == String

      Returns:
        the unique items from the array

    - #### public Object[] toUnique(Closure condition)

      Returns a new Array containing the items from the original Array but with duplicates removed with the supplied comparator determining which items are unique.

          String[] letters = ['c', 'a', 't', 's', 'A', 't', 'h', 'a', 'T']
          String[] expected = ['c', 'a', 't', 's', 'h']
          assert letters.toUnique{ p1, p2 -> p1.toLowerCase() <=> p2.toLowerCase() } == expected
          assert letters.toUnique{ it.toLowerCase() } == expected

      Parameters:
        `condition` - a Closure used to determine unique items
      Returns:
        the unique items from the array

    - #### public Object[] toUnique(Comparator comparator)

      Returns a new Array containing the items from the original Array but with duplicates removed with the supplied comparator determining which items are unique.

          String[] letters = ['c', 'a', 't', 's', 'A', 't', 'h', 'a', 'T']
          String[] lower = ['c', 'a', 't', 's', 'h']
          class LowerComparator implements Comparator {
              int compare(let1, let2) { let1.toLowerCase() <=> let2.toLowerCase() }
          }
          assert letters.toUnique(new LowerComparator()) == lower

      Parameters:
        `comparator` - a Comparator used to determine unique (equal) items If `null`, the Comparable natural ordering of the elements will be used.
      Returns:
        the unique items from the array