Kernel.hd

You're seeing just the function hd, go back to Kernel module for more information.

Specs

hd(nonempty_maybe_improper_list(elem, any())) :: elem when elem: term()

Returns the head of a list. Raises ArgumentError if the list is empty.

It works with improper lists.

Allowed in guard tests. Inlined by the compiler.

Examples

hd([1, 2, 3, 4])
#=> 1

hd([1 | 2])
#=> 1

Giving it an empty list raises:

tl([])
#=> ** (ArgumentError) argument error