Back to Lo

Core Nth

docs/data/core-nth.md

1.53.0214 B
Original Source

Returns the element at index nth of collection. If nth is negative, returns the nth element from the end. Returns an error when nth is out of slice bounds.

go
v, _ := lo.Nth([]int{10, 20, 30}, 1)
// v == 20