Enum.into
You're seeing just the function
into
, go back to Enum module for more information.
Specs
into(Enumerable.t(), Collectable.t()) :: Collectable.t()
Inserts the given enumerable
into a collectable
.
Note that passing a non-empty list as the collectable
is deprecated. If you're collecting
into a non-empty keyword list, consider using Keyword.merge(collectable, Enum.to_list(enumerable))
.
If you're collecting into a non-empty list, consider something like Enum.to_list(enumerable) ++ collectable
.
Examples
iex> Enum.into([1, 2], [])
[1, 2]
iex> Enum.into([a: 1, b: 2], %{})
%{a: 1, b: 2}
iex> Enum.into(%{a: 1}, %{b: 2})
%{a: 1, b: 2}
iex> Enum.into([a: 1, a: 2], %{})
%{a: 2}
Specs
into(Enumerable.t(), Collectable.t(), (term() -> term())) :: Collectable.t()
Inserts the given enumerable
into a collectable
according to the
transformation function.
Examples
iex> Enum.into([2, 3], [3], fn x -> x * 3 end)
[3, 6, 9]
iex> Enum.into(%{a: 1, b: 2}, %{c: 3}, fn {k, v} -> {k, v * 2} end)
%{a: 2, b: 4, c: 3}