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

28 lines
497 B
Markdown

---
name: FirstOrEmpty
slug: firstorempty
sourceRef: find.go#L567
category: core
subCategory: find
playUrl: https://go.dev/play/p/i200n9wgrDA
variantHelpers:
- core#find#firstorempty
similarHelpers:
- core#find#first
- core#find#firstor
- core#find#lastorempty
- core#find#nthorempty
position: 270
signatures:
- "func FirstOrEmpty[T any](collection []T) T"
---
Returns the first element of a collection or the zero value if empty.
```go
v := lo.FirstOrEmpty([]int{})
// v == 0
```