OkThen.Result.Enum.collect_tagged
You're seeing just the function
collect_tagged
, go back to OkThen.Result.Enum module for more information.
Link to this function
collect_tagged(results, tag)
Specs
collect_tagged([OkThen.Result.tagged()], atom()) :: {atom(), [any()]}
Collects an Enum of results into a single result. If all results were tagged with the specified
tag
, then a result will be returned tagged with tag
, whose value is a list of the wrapped
values from each element in the list. Otherwise, the result whose tag didn't match tag
is
returned.
Examples
iex> [:ok, :ok]
...> |> Result.Enum.collect_tagged(:ok)
{:ok, [{}, {}]}
iex> [:ok, :ok, :ok, :error, {:error, 2}]
...> |> Result.Enum.collect_tagged(:ok)
{:error, {}}
iex> [{:ok, 1}, {:ok, 1, 2}, :ok]
...> |> Result.Enum.collect_tagged(:ok)
{:ok, [1, {1, 2}, {}]}
iex> [{:ok, 1}, {:ok, 1, 2}, {:something, 1}, :ok]
...> |> Result.Enum.collect_tagged(:ok)
{:something, 1}
iex> []
...> |> Result.Enum.collect_tagged(:ok)
{:ok, []}