<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppIntentsTesting",
  "identifier" : "/documentation/AppIntentsTesting/DynamicPropertyPath/subscript(_:)-1hj9z",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Subscript",
  "symbol" : {
    "kind" : "Instance Subscript",
    "modules" : [
      "App Intents Testing"
    ],
    "preciseIdentifier" : "s:17AppIntentsTesting19DynamicPropertyPathVy0aB11TypeSupport21IntentValueExpressing_pSgSicip"
  },
  "title" : "subscript(_:)"
}
-->

# subscript(_:)

Accesses a collection element by index, without casting.

```
subscript(index: Int) -> (any IntentValueExpressing)? { get throws }
```

## Overview

The code below shows the syntactic sugar
and the equivalent, desugared, subscript syntax.

```swift
let result = try await intent.run() // Expected an array as result value

result.value[0] == nil
CreateCoffeeIntent.makeIntent(customerName: result.value[0])
```

For more information about dynamic-member syntax,
see [dynamicMemberLookup](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/attributes#dynamicMemberLookup) in *[The Swift Programming Language](https://docs.swift.org/swift-book/)*.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)