OkThen.Result.Enum.group_by_tag
You're seeing just the function
group_by_tag
, go back to OkThen.Result.Enum module for more information.
Link to this function
group_by_tag(results)
Specs
group_by_tag([OkThen.Result.tagged()]) :: %{required(atom()) => [any()]}
Collects an Enum of results into a map, with result values grouped by their tag.
Examples
iex> [:ok, :ok, :ok, :error, :error]
...> |> Result.Enum.group_by_tag()
%{
error: [{}, {}],
ok: [{}, {}, {}]
}
iex> [{:ok, 1}, {:ok, 2}, {:ok, 3}, {:error, 4}, {:error, 5}]
...> |> Result.Enum.group_by_tag()
%{
error: [4, 5],
ok: [1, 2, 3]
}
iex> [{:ok, 1}, {:ok, 2, 3}, :none, {:error, 4}, {:another, 5}]
...> |> Result.Enum.group_by_tag()
%{
another: [5],
error: [4],
none: [{}],
ok: [1, {2, 3}]
}