Adds &Kernel.identity/1 (#9182)
This commit is contained in:
committed by
Fernando Tapia Rico
parent
3366cebc7d
commit
6c1894de6b
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user