Byte array functions

# Name Description Complexity
1 drop(ByteVector, Int): ByteVector Returns the byte array without the first N bytes 1
2 dropRight(ByteVector, Int): ByteVector Returns the byte array without the last N bytes 19
3 size(ByteVector): Int Returns the number of bytes in the byte array 1
4 take(ByteVector, Int): ByteVector Returns the first N bytes of the byte array 1
5 takeRight(ByteVector, Int): ByteVector Returns the last N bytes of the byte array 19

drop(ByteVector, Int): ByteVector

Returns the byte array without the first N bytes.

drop(xs: ByteVector, number: Int): ByteVector

Parameters

xs: ByteVector

Byte array.

Examples

drop("Ride".toBytes(), 2)   # Returns the byte array without the first 2 bytes
drop(125.toBytes(), 2)      # Returns the byte array without the first 2 bytes
drop(base16'52696465', 3)   # Returns the byte array without the first 3 bytes
drop(base58'37BPKA', 3)     # Returns the byte array without the first 3 bytes
drop(base64'UmlkZQ==', 3)   # Returns the byte array without the first 3 bytes

number: Int

Number N.

dropRight(ByteVector, Int): ByteVector

Returns the byte array without the last N bytes.

dropRight(xs: ByteVector, number: Int): ByteVector

Parameters

xs: ByteVector

Byte array.

number: Int

Number N.

Examples

dropRight("Ride".toBytes(), 2)  # Returns the byte array without the last 2 bytes
dropRight(125.toBytes(), 2)     # Returns the byte array without the last 2 bytes
dropRight(base16'52696465', 3)  # Returns the byte array without the last 3 bytes
dropRight(base58'37BPKA', 3)    # Returns the byte array without the last 3 bytes
dropRight(base64'UmlkZQ==', 3)  # Returns the byte array without the last 3 bytes

size(ByteVector): Int

Returns the number of bytes in the byte array.

size(byteVector: ByteVector): Int

Parameters

byteVector: ByteVector

Byte array.

Examples

size("Hello".toBytes())         # Returns 5
size("Hello world".toBytes())   # Returns 11
size(64.toBytes())              # Returns 8 because all integers in Ride take 8 bytes
size(200000.toBytes())          # Returns 8 because all integers in Ride take 8 bytes
size(base58'37BPKA')            # Returns 4

take(ByteVector, Int): ByteVector

Returns the first N bytes of the byte array.

take(xs: ByteVector, number: Int): ByteVector

Parameters

xs: ByteVector

Byte array.

number: Int

Number N.

Examples

take(base58'37BPKA', 0) # Returns the empty byte array
take(base58'37BPKA', 1) # Returns the byte array consisting of first byte of initial byte array
take(base58'37BPKA', 15) # Returns whole byte array
take(base58'37BPKA', -10) # Returns the empty byte array

takeRight(ByteVector, Int): ByteVector

Returns the last N bytes of the byte array.

takeRight(xs: ByteVector, number: Int): ByteVector

Parameters

xs: ByteVector

Byte array.

number: Int

Number N.

Examples

takeRight(base58'37BPKA', 2) # Returns the last 2 bytes of the byte array

results matching ""

    No results matching ""