---
title: "subscript(_:)"
framework: gameplaykit
role: symbol
role_heading: Instance Subscript
path: "gameplaykit/gkbehavior/subscript(_:)-997a9"
---

# subscript(_:)

Returns the goal at the specified index in the behavior’s list of goals.

## Declaration

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

## Parameters

- `idx`: An index in the behavior’s list of goals; must be less than the value of the doc://com.apple.gameplaykit/documentation/GameplayKit/GKBehavior/goalCount property.

## Return Value

Return Value The goal at the specified index.

## Discussion

Discussion The order of goals in a behavior is undefined. However, you can use this method to enumerate all goals in a behavior.

## See Also

### Working with Goals Using Subscript Syntax

- [subscript(_:)](gameplaykit/gkbehavior/subscript(_:)-2yvko.md)
