"ByteArray" (Compiled Type)

"ByteArray"

represents a one-dimensional array of bytes.

Details

  • "ByteArray" can be used in Typed and related constructs to specify a type.

Constructors

  • ByteArray["string"] constructs a "ByteArray" object by extracting byte values from a Base64-encoded string.
  • ByteArray[na] constructs a copy of the array na, where na has the type "NumericArray"::["UnsignedInteger8", 1].
  • CreateTypeInstance["ByteArray",len] constructs a byte array of length len.
  • CreateTypeInstance["ByteArray",byte,len] constructs a byte array of length len filled with byte values.

Conversions

    Expressions

  • "ByteArray" objects can be converted to and from ByteArray expressions.
  • "NumericArray"

  • "ByteArray" objects can be converted to and from "NumericArray"::["UnsignedInteger8",1] objects.

Runtime Errors

    ArrayPartError

  • Operations that require extracting elements from a "ByteArray" can give a runtime error if those elements do not exist.
  • Cast

  • Casting from or to a "ByteArray" object can give a runtime error if the object cannot be converted to the target type.

Examples

open allclose all

Basic Examples  (2)

"ByteArray" can be used as input or output for a CompiledCodeFunction:

Create a "ByteArray" in compiled code:

Scope  (8)

Construction  (4)

Construct a "ByteArray" from a string:

Construct a "ByteArray" from a numeric array:

Create a "ByteArray" instance of a given length:

Note that the created byte array is filled with random values:

Create a "ByteArray" instance of a given length filled with an initial value:

Conversion  (4)

Convert a "ByteArray" to a "NumericArray":

Convert a "ByteArray" from a "NumericArray":

Convert a "ByteArray" to an "InertExpression":

Convert a "ByteArray" from an "InertExpression":

Properties & Relations  (5)

Get the length:

Get the head:

Get an element:

Convert a "ByteArray" to a normal expression:

Convert a "ByteArray" to a string:

Possible Issues  (2)

Part access can cause a runtime error if the element does not exist:

Casting can cause a runtime error if the object cannot be converted to the target type: