Overview | Package | Class | Tree | Deprecated | Index | Help
| Groovy JDK

## java.lang
Class Object[]

Method Summary
`boolean` | `asBoolean()` Coerce an Object array to a boolean value.
`Object` | `asType(Class clazz)` Converts the given array to either a List, Set, or SortedSet.
`Number` | `count(Object value)` Counts the number of occurrences of the given value inside this array.
`boolean` | `equals(List right)` Determines if the contents of this array are equal to the contents of the given list, in the same order.
`Collection` | `flatten()` Flatten an array.
`Object` | `inject(Object initialValue, Closure closure)` Iterates through the given array of objects, passing in the initial value to the closure along with the current iterated item then passing into the next iteration the value of the previous closure.
`String` | `join(String separator)` Concatenates the `toString()` representation of each items in this array, with the given String as a separator between each item.
`int` | `size()` Provide the standard Groovy `size()` method for an array.
`String` | `toArrayString()` Returns the string representation of the given array.
`SpreadMap` | `toSpreadMap()` Creates a spreadable map from this array.
`String` | `toString()` Returns the string representation of this array's contents.

Method Detail

### asBoolean

    public boolean asBoolean()

  Coerce an Object array to a boolean value. An Object array is false if the array is of length 0. and to true otherwise

Returns:
  the boolean value

Since:
  1.7.0

### asType

    public Object asType(Class clazz)

  Converts the given array to either a List, Set, or SortedSet. If the given class is something else, the call is deferred to {link #asType(Object,Class)}.

Parameters:
  `clazz` - the desired class.

Returns:
  the object resulting from this type conversion

Since:
  1.5.1

See:
  #asType(Object,Class).

### count

    public Number count(Object value)

  Counts the number of occurrences of the given value inside this array. Comparison is done using Groovy's == operator (using `compareTo(value) == 0` or `equals(value)` ).

Parameters:
  `value` - the value being searched for.

Returns:
  the number of occurrences

Since:
  1.6.4

### equals

    public boolean equals(List right)

  Determines if the contents of this array are equal to the contents of the given list, in the same order. This returns `false` if either collection is `null`.

Parameters:
  `right` - the list being compared.

Returns:
  true if the contents of both collections are equal

Since:
  1.5.0

### flatten

    public Collection flatten()

  Flatten an array. This array and any nested arrays or collections have their contents (recursively) added to the new collection.

Returns:
  a flattened Collection

Since:
  1.6.0

### inject

    public Object inject(Object initialValue, Closure closure)

  Iterates through the given array of objects, passing in the initial value to the closure along with the current iterated item then passing into the next iteration the value of the previous closure.

Parameters:
  `initialValue` - an initialValue.
  `closure` - a closure.

Returns:
  the last value of the last iteration

Since:
  1.5.0

### join

    public String join(String separator)

  Concatenates the `toString()` representation of each items in this array, with the given String as a separator between each item.

Parameters:
  `separator` - a String separator.

Returns:
  the joined String

Since:
  1.0

### size

    public int size()

  Provide the standard Groovy `size()` method for an array.

Returns:
  the size (length) of the Array

Since:
  1.0

### toArrayString

    public String toArrayString()

  Returns the string representation of the given array. The string displays the contents of the array, similar to an array literal, i.e. `{1, 2, "a"}`.

Returns:
  the string representation

Since:
  1.0

### toSpreadMap

    public SpreadMap toSpreadMap()

  Creates a spreadable map from this array.

Returns:
  a newly created Spreadmap

Since:
  1.0

See:
  SpreadMap#SpreadMap.

### toString

    public String toString()

  Returns the string representation of this array's contents.

Returns:
  the string representation

Since:
  1.0

See:
  #toArrayString(Object[]).

Overview | Package | Class | Tree | Deprecated | Index | Help
| Groovy JDK