<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreAI",
  "identifier" : "/documentation/CoreAI/NDArray/init(shape:scalarType:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core AI",
      "CoreAI"
    ],
    "preciseIdentifier" : "s:13CoreAIRuntime7NDArrayV5shape10scalarTypeACSaySiG_AC06ScalarF0Otcfc"
  },
  "title" : "init(shape:scalarType:)"
}
-->

# init(shape:scalarType:)

Creates an array with the specified shape and scalar type.

```
init(shape: [Int], scalarType: NDArray.ScalarType)
```

## Parameters

`shape`

The length of each dimension.

`scalarType`

The scalar element type.

## Discussion

This initializer creates an array with contiguous, row-major strides.

---

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)