---
title: "contains(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsarray/contains(_:)"
---

# contains(_:)

Returns a Boolean value that indicates whether a given object is present in the array.

## Declaration

```swift
func contains(_ anObject: Any) -> Bool
```

## Parameters

- `anObject`: An object to look for in the array.

## Return Value

Return Value true if anObject is present in the array, otherwise false.

## Discussion

Discussion Starting at index 0, each element of the array is checked for equality with anObject until a match is found or the end of the array is reached.  Objects are considered equal if isEqual(_:) returns true. To determine if the array contains a particular instance of an object, you can test for identity rather than equality by calling the indexOfObjectIdentical(to:) method and comparing the return value to NSNotFound.

## See Also

### Related Documentation

- [indexOfObjectIdentical(to:)](foundation/nsarray/indexofobjectidentical(to:).md)
- [index(of:)](foundation/nsarray/index(of:).md)

### Querying an Array

- [count](foundation/nsarray/count.md)
- [firstObject](foundation/nsarray/firstobject.md)
- [lastObject](foundation/nsarray/lastobject.md)
- [object(at:)](foundation/nsarray/object(at:).md)
- [subscript(_:)](foundation/nsarray/subscript(_:).md)
- [objects(at:)](foundation/nsarray/objects(at:).md)
- [objectEnumerator()](foundation/nsarray/objectenumerator().md)
- [reverseObjectEnumerator()](foundation/nsarray/reverseobjectenumerator().md)
