Reputation: 2226
Is there an identity function already defined Elixir ?
Something like:
identity = fn a -> a end
Upvotes: 35
Views: 5027
Reputation: 8280
@focused is correct - 1.10-dev has added the identity function.
Old Answer:
No such function has been predefined (at least that I'm aware of). It can trivially be written as you've done in your question, or more succinctly as &(&1)
.
Upvotes: 40