Back to Lo

Core Nthorempty

docs/data/core-nthorempty.md

1.53.0204 B
Original Source

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

go
v := lo.NthOrEmpty([]int{10, 20, 30}, 10)
// v == 0