Skip to content
FutureBlitz

    Install

    Learn

    Collections

    Arrays, slices and ranges, Maps and Sets, loops over them, iterators, and std.collections' other types.

    Most programs keep many values: a list of scores, a table of prices by name, a queue of jobs. This area covers the built-in array, the slices and ranges that pick out parts of one, and the standard library’s collections, from Map and Set to stacks, queues, and sorted maps. It also shows how For ... In goes over any of them, and how an iterator produces values one at a time, only as they’re asked for. Every collection here is checked: reading past the end of an array or a missing key from a Map stops the program with a message, instead of reading memory that isn’t there.

    Tutorials

    1. Arrays Make a list that grows, change it, copy it, and use fixed-size arrays for data of a set size.
    2. Indexing and ranges Read and change values by index, copy part of an array with a slice, and count with ranges.
    3. Maps and Sets Look values up by key with Map, count with a default, and keep unique values in a Set.
    4. Iterating with For ... In Go over arrays, Maps, Sets, ranges, and strings with For ... In, and know what a loop can change.
    5. Sequences and iterators Write an iterator that makes values one at a time, chain lazy steps on it, and give a type of your own a For loop.
    6. std.collections' other types Stacks, queues, priority queues, sorted maps, counters, and ring buffers, and when to use each.

    The rules behind this area are in the language reference.

    Report an issue with this page or with FutureBlitz on GitHub.