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

# subscript(_:)

Returns an attribute value that corresponds to an attributed string key.

## Declaration

```swift
subscript<K>(_: K.Type) -> K.Value? where K : AttributedStringKey, K.Value : Sendable { get set }
```

## Overview

Overview This subscript returns nil unless the specified attribute exists, and is present and identical for the entire discontiguous attributed substring. To find portions of an attributed string with consistent attributes, use the runs property. Getting or setting stringwide attributes with this subscript has O(n) behavior in the worst case, where n is the number of runs.
