SplitScript reference / String / byteAt
String.byteAt
Method
String.byteAt(byteIndex: u32) -> u8!
Returns the raw UTF-8 byte at an offset.
The index uses the same zero-based byte offsets as byteLength and slice. Every in-range byte is observable, including a continuation byte within a multibyte code point. An out-of-range index returns an error.
Parameters
byteIndex: The zero-based UTF-8 byte offset.
Effects: allocates
Runtime behavior: available everywhere; synchronous
Examples
Inspect a fixed-format ASCII identifier
let separator = "map_01".byteAt(3) else 0
if separator == 0x5f {
print("Found the separator")
}