hd-lang

Tour · 15 of 25

A list or map is typed by what it holds, and a lookup that may miss says so

[...] builds a List and {key: value} a Map, both from the prelude. Every element has the collection's type, so a Map[string, i32] never hands back a string. Indexing a map with wanted[item] = ... sets an entry, but reading one is get, which gives an i32?, because the key may be absent. You decide what a missing key means, here zero on hand. A comprehension puts its clauses before => and the value after it, and iter() starts a chain of steps such as map and sum.

Run: Ctrl+Enter · Pages: Alt+← Alt+→