typeover
curriculum

Curriculum Collections

module 2 of 7

Collections

Arrays, slices, maps, and the for-range loop. The translation pattern still works but the wrinkles deepen: slices are views, map iteration is unordered, and range gives you index+value.


themes

Go has fixed-size arrays ([N]T) and dynamically-sized slices ([]T). You almost always want slices. A slice is a view over a backing array — three machine words: pointer…

11 ready begin →

2.2

Maps

map[K]V. Like a TS Record<K, V> or Map<K, V>. Lookup with comma-ok: v, ok := m[key]. Iteration order is undefined — every range yields a different ordering. Maps are re…

10 ready begin →

for i, v := range collection is the workhorse. Over a slice you get (index, value). Over a map you get (key, value). Over a string you get (byteIndex, rune). Over a channel…

11 ready begin →