or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

array-runtime.mdboxing-unboxing.mdconcurrent-collections.mdindex.mdmathematical-support.mdreference-types.md

array-runtime.mddocs/

0

# Array Runtime Support

1

2

Array cloning utilities supporting all primitive array types and object arrays with proper type preservation. The ArrayRuntime object provides essential array operations for the Scala Native runtime system.

3

4

## Core Imports

5

6

```scala

7

import scala.runtime.ArrayRuntime

8

```

9

10

## Capabilities

11

12

### Array Cloning

13

14

Creates shallow copies of arrays for all primitive types and object arrays.

15

16

```scala { .api }

17

object ArrayRuntime {

18

def cloneArray(array: Array[Boolean]): Array[Boolean]

19

def cloneArray(array: Array[Byte]): Array[Byte]

20

def cloneArray(array: Array[Short]): Array[Short]

21

def cloneArray(array: Array[Char]): Array[Char]

22

def cloneArray(array: Array[Int]): Array[Int]

23

def cloneArray(array: Array[Long]): Array[Long]

24

def cloneArray(array: Array[Float]): Array[Float]

25

def cloneArray(array: Array[Double]): Array[Double]

26

def cloneArray(array: Array[java.lang.Object]): Array[java.lang.Object]

27

}

28

```

29

30

## Usage Examples

31

32

```scala

33

import scala.runtime.ArrayRuntime

34

35

// Clone primitive arrays

36

val intArray = Array(1, 2, 3, 4, 5)

37

val clonedIntArray = ArrayRuntime.cloneArray(intArray)

38

39

val doubleArray = Array(1.0, 2.0, 3.0)

40

val clonedDoubleArray = ArrayRuntime.cloneArray(doubleArray)

41

42

// Clone object arrays

43

val stringArray = Array("hello", "world")

44

val clonedStringArray = ArrayRuntime.cloneArray(stringArray.asInstanceOf[Array[java.lang.Object]])

45

46

// The cloned arrays are independent

47

clonedIntArray(0) = 100

48

println(intArray(0)) // 1 (original unchanged)

49

println(clonedIntArray(0)) // 100 (clone modified)

50

```

51

52

## Notes

53

54

- All `cloneArray` methods perform shallow copying

55

- For object arrays, only the array container is cloned, not the contained objects

56

- The cloned arrays are completely independent of the original arrays

57

- Type preservation is maintained through method overloading