Official documentation and IEx response don't agree

The official (ver 1.9.1) online list of commands available for use with a list includes first/1 and last/1 but IEx distributed with 1.9.1 returns ** (CompileError) iex:19: undefined function first/1
and same for last/1. Why is that?


It should probably be called via fully qualified function name: List.first(list) and List.last(list).

To be able to call it as first(list) and last(list), these functions would need to be imported with something like import List, only: [first: 1, last: 1] or simply import List. The latter would import all public functions in List module.

1 Like

Thank you. The response you provide is both thorough and helpful.