Safely get the first item from a list, returning Just the first item if the array has at least one item in it, or Nothing if it is empty.
Just
Nothing
let empty = [];Maybe.head(empty); // => Nothinglet full = [1, 2, 3];Maybe.head(full); // => Just(1) Copy
let empty = [];Maybe.head(empty); // => Nothinglet full = [1, 2, 3];Maybe.head(full); // => Just(1)
The array to get the first item from.
Safely get the first item from a list, returning
Just
the first item if the array has at least one item in it, orNothing
if it is empty.Examples