Home / Docs / Standard library / Built-in methods
values
A built-in method, resolved by the type of its receiver (spec/14 §2). Edition 0.2 and later.
Edition 0.2 and later
m.values() -> List[V]
where m: Map[K, V]The values of m, in the order of their keys, as many as m.len (spec/21 §2). On a HashMap, in the order the keys were first added, in O(n) (spec/28 §7).
Edition 0.5 preview
m.values() -> List[V]
where m: Map[K, V]
m.values() -> List[V]
where m: HashMap[K, V]The values of m, in the order of their keys, as many as m.len (spec/21 §2). On a HashMap, in the order the keys were first added, in O(n) (spec/28 §7).
In editions 0.5. In edition 0.2, 0.3, 0.4: no HashMap[K, V] receiver, since std.collections begins in edition 0.5: it has no where m: HashMap[K, V].
Receiver
Map[K, V]: the mapmHashMap[K, V]: the hash mapm
Returns
List[V]: the values of m, in the order of their keys on a Map and in the order the keys were first added on a HashMap; as many as m.len.
See also
Example
module shop
--- A stock report, from the map's values.
pub main() -> Unit
uses @console: Console[print]
=
let stock = empty_map().with(key: "lamp", value: 3).with(key: "desk", value: 1)
let total = stock.values().sum()
@console.print("{total} units")una run . prints:
4 unitsSpecification
- spec/21 §2
spec/28 §7
Generated from una v0.4.0 (docs/std/builtins.json, which is not part of the specification): built-in methods have no declaration, so una writes these signature lines and tests each against its checker. The specification governs: spec/14 §2.