<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLShapedArrayProtocol/subscript(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Subscript",
  "symbol" : {
    "kind" : "Instance Subscript",
    "modules" : [
      "Core ML"
    ],
    "preciseIdentifier" : "s:6CoreML21MLShapedArrayProtocolPyAA0cD5SliceVy6ScalarQzGqd__cSlRd__Si7ElementRtd__luip::OverloadGroup"
  },
  "title" : "subscript(_:)"
}
-->

# subscript(_:)

A slice of the shaped array for the selected leading axes.

```
subscript<C>(indices: C) -> MLShapedArraySlice<Self.Scalar> where C : Collection, C.Element == Int { get set }
```

## Parameters

`indices`

The indices to slice the array.

## Overview

The slice has a rank of `self.rank - indices.count`. For example, given a shaped array `m`
with the shape being `3 x 3`, `m[[1]]` returns a slice of shape `[3]` with the contents
labeld as `x` below.

```
 O  O  O
 x  x  x
 O  O  O
```

---

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)