# [Ride v4 and v3] Byte array functions
⚠️ This is the documentation for the Standard library version 4 and 3. We recommend to use version 6. Go to version 6
# | Name | Description | Complexity |
---|---|---|---|
1 | drop(ByteVector, Int): ByteVector | Returns the byte array without the first N bytes | 1 for Standard Library version 3 6 for Standard Library version 4 |
2 | dropRight(ByteVector, Int): ByteVector | Returns the byte array without the last N bytes | 19 for Standard Library version 3 6 for Standard Library version 4 |
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 for Standard Library version 3 6 for Standard Library version 4 |
5 | takeRight(ByteVector, Int): ByteVector | Returns the last N bytes of the byte array | 19 for Standard Library version 3 6 for Standard Library version 4 |
# 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