typeover
curriculum

Curriculum Basics Strings as slices exercise 1 · mcq

Strings as slices

TypeScript writes const greeting: string = "hello";. Zig has no string type — string literals are byte slices. Pick the idiomatic Zig translation.

TypeScript reference
Pick the idiomatic Go translation

About this theme

There's no String type in Zig. String literals are byte slices typed as []const u8 — same shape as any other slice of read-only bytes. Length comes from .len (a usize), indexing returns a single u8 byte, and substring with s[a..b] produces another []const u8. The mental model from TypeScript needs one shift: a Zig string isn't a value-typed character sequence, it's a view into bytes.