<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLShapedArraySlice/init(scalars:shape:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core ML"
    ],
    "preciseIdentifier" : "s:6CoreML18MLShapedArraySliceV7scalars5shapeACyxGqd___SaySiGtc7ElementQyd__RszSTRd__lufc"
  },
  "title" : "init(scalars:shape:)"
}
-->

# init(scalars:shape:)

Initialize with a sequence and the shape.

```
init<S>(scalars: S, shape: [Int]) where Scalar == S.Element, S : Sequence
```

## Parameters

`scalars`

The initializing sequence.

`shape`

The shape

## Discussion

The length of the sequence must not be less than the number of scalars in the shaped array.

---

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)