Strings & Bytes
#
StringsStrings are defined using the built-in string
type like this:
#
Concatenating StringsStrings can be concatenated using the +
operator.
#
Extracting SubstringsSubstrings can be extracted using the predefined function
String.sub
. The first character has index 0 and the interval of
indices for the substring has inclusive bounds.
⚠️ Notice that the offset and length of the slice are natural numbers.
#
Length of StringsThe length of a string can be found using a built-in function:
#
BytesByte literals are defined using the prefix 0x
followed by hexadecimal digits like this:
#
Concatenating BytesBytes can be concatenated using the Bytes.concat
function.
#
Extracting BytesBytes can be extracted using the predefined function Bytes.sub
.
The first parameter takes the start index and the second parameter takes the number of bytes.
Pay special attention to how bytes
are indexed.
#
Length of BytesThe length of bytes
can be found using a built-in function Bytes.length
: