Slide 7 of 37

Vectors

proc main(): void {
	v := ["a", "b", "c"]          // Str[3] — a static length, inferred
	mut Str[dyn] w = ["a", "b"]    // dynamic — the only kind append accepts
	append(w, "c")

	first := v[0]
	middle := v[0:1]                // slicing, both bounds inclusive
	echo "{first} {middle} {w}"
}
A vector is memory-contiguous and homogeneous. Str[3] is static: exactly three, always. Str[dyn] is dynamic: it promises nothing about its length and is the only kind append works on. Str[] is a parameter-only spelling that accepts either. A variable or field must say which of the two real kinds it holds — that promise is what the bounds checker rests on. + concatenates into a new vector; == compares structurally, element by element.