Files
lo/docs/data/core-nthor.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

590 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
NthOr nthor find.go#L635 core find https://go.dev/play/p/njKcNhBBVsF
core#find#nthor
core#find#nthorempty
core#find#nth
core#find#findorelse
core#find#firstor
330
func NthOr[T any, N constraints.Integer](collection []T, nth N, fallback T) T

Returns the element at index nth of collection, or the fallback if out of bounds. If nth is negative, returns the nth element from the end.

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