aboutsummaryrefslogtreecommitdiff
path: root/src/content/chapter4_standard_library/lesson03_dict_module/en.html
blob: 4037085409dd2a0880ca04dc85311b8c518c451d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<p>
  The
  <a href="https://hexdocs.pm/gleam_stdlib/gleam/dict.html"
    ><code>gleam/dict</code></a
  >
  standard library module defines Gleam's <code>Dict</code> type and functions
  for working with it. A dict is a collection of keys and values which other
  languages may call a hashmap or table.
</p>

<p>
  <a href="https://hexdocs.pm/gleam_stdlib/gleam/dict.html#new" target="_blank">
    <code>new</code>
  </a>
  and
  <a href="https://hexdocs.pm/gleam_stdlib/gleam/dict.html#from_list" target="_blank">
    <code>from_list</code>
  </a>
  can be used to create new dicts.
</p>

<p>
  <a href="https://hexdocs.pm/gleam_stdlib/gleam/dict.html#insert" target="_blank">
    <code>insert</code>
  </a>
  and
  <a href="https://hexdocs.pm/gleam_stdlib/gleam/dict.html#delete" target="_blank">
    <code>delete</code>
  </a>
  are used to add and remove items from a dict.
</p>
<p>
  Like lists, dicts are immutable. Inserting or deleting an item from a dict
  will return a new dict with the item added or removed.
</p>
<p>
  Dicts are unordered! If it appears that the items in a dict are in a certain
  order this is incidental and should not be relied upon. Any ordering may
  change without warning in future versions or on different runtimes.
</p>