We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5d48b21 commit be4eb9aCopy full SHA for be4eb9a
lib/together/map.ex
@@ -13,10 +13,13 @@ defmodule Together.Map do
13
iex> invert(%{a: 1, b: 2})
14
%{1 => :a, 2 => :b}
15
16
- # this one depends a bit on ordering of the map inside the BEAM, but wanted to show that
17
- # no values get aggregated.
18
- iex> invert(%{a: 1, b: 1})
19
- %{1 => :b}
+ # a bit weird, but the point is showing that if values are duplicated one of the keys "survives",
+ # while the other is dropped, whether :a or :b "survive" is non deterministic.
+ iex> result = invert(%{a: 1, b: 1})
+ iex> Map.keys(result)
20
+ [1]
21
+ iex> result[1] in [:a, :b]
22
+ true
23
24
iex> invert(%{})
25
%{}
0 commit comments