Contents

subscript(_:)

Returns the object at the specified index.

Declaration

subscript(idx: Int) -> Any { get }
subscript(idx: Int) -> Any { get set }

Parameters

  • idx:

    An index within the bounds of the array.

Return Value

The object located at idx.

Discussion

This method has the same behavior as the object(at:) method.

If idx is beyond the end of the array (that is, if idx is greater than or equal to the value returned by count), an rangeException is raised.

You shouldn’t need to call this method directly. Instead, this method is called when accessing an object by index using subscripting.

id value = array[3]; // equivalent to [array objectAtIndex:3]

See Also

Querying an Array