Skip to content

Selection

This section contains functions to select elements from a slice.

First

First returns the first element in a slice.

Usage:

slice.First([]int{1, 2, 3}) // 1

Pop

Pop removes and returns the element from a slice.

Usage:

slice, val := slice.Pop([]int{1, 2, 3}) // slice: []int{1, 2}, val: 3
slice, val := slice.Pop([]int{1, 2, 3}, 0) // slice: []int{2, 3}, val: 1