---
title: "subscript(_:)"
framework: swift
role: symbol
role_heading: Instance Subscript
path: "swift/slice/subscript(_:)-1rloy"
---

# subscript(_:)

Accesses the element at the specified position.

## Declaration

```swift
subscript(index: Slice<Base>.Index) -> Base.Element { get }
```

## Overview

Overview The following example accesses an element of an array through its subscript to print its value: var streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"] print(streets[1]) // Prints "Bryant" You can subscript a collection with any valid index other than the collection’s end index. The end index refers to the position one past the last element of a collection, so it doesn’t correspond with an element. note: O(1)
