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

488 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
FirstOr firstor find.go#L574 core find https://go.dev/play/p/x9CxQyRFXeZ
core#find#firstor
core#find#first
core#find#firstorempty
core#find#lastor
core#find#nthor
280
func FirstOr[T any](collection []T, fallback T) T

Returns the first element of a collection or the fallback value if empty.

v := lo.FirstOr([]int{}, -1)
// v == -1