Strings In Depth14 / 19
Up next

Slice by byte offset

const std = @import("std");

pub fn main() void {
    const s = "hello";
    // slicing is by byte offset; end is excluded
    const hi = s[0..2];
    std.debug.print("{s}\n", .{hi});
}
What you're solving

s[a..b] indexes bytes, half-open