Skip to content

Commit be4eb9a

Browse files
committed
Make map test deterministic/more appropraite
1 parent 5d48b21 commit be4eb9a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/together/map.ex

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ defmodule Together.Map do
1313
iex> invert(%{a: 1, b: 2})
1414
%{1 => :a, 2 => :b}
1515
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}
16+
# a bit weird, but the point is showing that if values are duplicated one of the keys "survives",
17+
# while the other is dropped, whether :a or :b "survive" is non deterministic.
18+
iex> result = invert(%{a: 1, b: 1})
19+
iex> Map.keys(result)
20+
[1]
21+
iex> result[1] in [:a, :b]
22+
true
2023
2124
iex> invert(%{})
2225
%{}

0 commit comments

Comments
 (0)