Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

array.int16

import array

Everything here is re-exported by array, so import array is enough and the names are called as array.*. Importing array.int16 on its own works too and reaches the same definitions.

Int16Array: a packed array of twos-complement 16-bit signed integers, 2 bytes per element.

INT16_MAX and INT16_MIN bound what an element may be; a value outside them raises rather than wrapping.

Constants

INT16_MAX

array.INT16_MAX: number = 32767

Maximum value that “should” exist in a list passed to Int16Array.

INT16_MIN

array.INT16_MIN: number

Minimum value that “should” exist in a list passed to Int16Array.

Classes

Int16Array

class array.Int16Array < Array

class Int16Array represents an array of twos-complement 16-bit signed integers in the platform byte order.

  • printable — has a @to_string(), so echo and print() show something useful
  • serializable — has a @to_json(), so it can be handed straight to json.encode()
  • valueable — has a @to_value(), so it converts to a plain Zuri value

Int16Array.reverse()

array.Int16Array.reverse() -> Int16Array

Returns a new array containing the elements in the original array in reverse order.

Returns Int16Array

Int16Array.clone()

array.Int16Array.clone() -> Int16Array

Returns a new Int16Array containing all items from the current array. The new array is a shallow copy of the original array.

Returns Int16Array

Int16Array.slice()

array.Int16Array.slice(start, end) -> Int16Array

Returns a new Int16Array over [start, end) of this array (both default to the whole array; negative bounds count from the end).

Parameters

  • start (?number)
  • end (?number)

Returns Int16Array


2021, Richard Ore and Zuri contributors