---
title: "subscript(_:)"
framework: foundation
role: symbol
role_heading: Instance Subscript
path: "foundation/nsorderedset/subscript(_:)"
---

# subscript(_:)

Returns the object at the specified index of the set.

## Declaration

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

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

## Parameters

- `idx`: The object located at index.

## Return Value

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

## Discussion

Discussion This method is the same as object(at:).

## See Also

### Accessing Set Members

- [contains(_:)](foundation/nsorderedset/contains(_:).md)
- [enumerateObjects(at:options:using:)](foundation/nsorderedset/enumerateobjects(at:options:using:).md)
- [enumerateObjects(_:)](foundation/nsorderedset/enumerateobjects(_:).md)
- [enumerateObjects(options:using:)](foundation/nsorderedset/enumerateobjects(options:using:).md)
- [firstObject](foundation/nsorderedset/firstobject.md)
- [lastObject](foundation/nsorderedset/lastobject.md)
- [object(at:)](foundation/nsorderedset/object(at:).md)
- [objects(at:)](foundation/nsorderedset/objects(at:).md)
- [index(of:)](foundation/nsorderedset/index(of:).md)
- [index(of:inSortedRange:options:usingComparator:)](foundation/nsorderedset/index(of:insortedrange:options:usingcomparator:).md)
- [index(ofObjectAt:options:passingTest:)](foundation/nsorderedset/index(ofobjectat:options:passingtest:).md)
- [index(ofObjectPassingTest:)](foundation/nsorderedset/index(ofobjectpassingtest:).md)
- [index(_:ofObjectPassingTest:)](foundation/nsorderedset/index(_:ofobjectpassingtest:).md)
- [indexes(ofObjectsAt:options:passingTest:)](foundation/nsorderedset/indexes(ofobjectsat:options:passingtest:).md)
- [indexes(ofObjectsPassingTest:)](foundation/nsorderedset/indexes(ofobjectspassingtest:).md)
