Home / Docs / Standard library / Prelude

empty_map

Release v0.4.0Edition 0.2 and later

A function of the prelude, in scope in every module. Edition 0.2 and later.

una
pub empty_map[K: Ord, V]() -> Map[K, V]
  ensures result.len == 0

The map with no entries, of the type its context expects (spec/21 §2).

Returns

Map[K, V]: the map with no entries, of the type its context expects; its len is 0.

See also

with, set

Example

src/shop.unauna
module shop

--- A stock count that starts empty.
pub main() -> Unit
  uses @console: Console[print]
=
  let stock: Map[Text, Int] = empty_map()
  @console.print("{stock.len} entries")

una run . prints:

Output
0 entries

Specification

Generated from the standard modules of una v0.4.0 (docs/std/listing.json, which is not part of the specification). The specification governs: spec/14 §1.