Adds &Kernel.identity/1 (#9182)

This commit is contained in:
Alexey Nikitin
2019-07-12 19:11:53 +02:00
committed by Fernando Tapia Rico
parent 3366cebc7d
commit 6c1894de6b
+20
View File
@@ -482,6 +482,26 @@ defmodule Kernel do
:erlang.floor(number)
end
@doc """
Returns its argument.
## Examples
iex> identity(17)
17
iex> identity(:ok)
:ok
iex> 'abcdaabccc' |> Enum.sort |> Enum.chunk_by(&identity/1)
['aaa', 'bb', 'cccc', 'd']
"""
@spec identity(a) :: a when a: var
def identity(a) do
a
end
@doc """
Returns the head of a list. Raises `ArgumentError` if the list is empty.