Files
lo/docs/data/core-nth.md
T
Samuel Berthe fa095e4b4f fix(doc): fix go playground demo URL (#832)
* fix(doc): fix go playground demo URL

* fix(doc): add more go playground demo URL
2026-03-06 00:09:59 +01:00

628 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
Nth nth find.go#L617 core find https://go.dev/play/p/mNFI9-kIZZ5
core#find#nth
core#find#first
core#find#last
core#find#nthor
core#find#nthorempty
core#slice#indexof
core#slice#drop
320
func Nth[T any, N constraints.Integer](collection []T, nth N) (T, error)

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.

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