mirror of
https://github.com/samber/lo.git
synced 2026-04-22 15:37:14 +08:00
fa095e4b4f
* fix(doc): fix go playground demo URL * fix(doc): add more go playground demo URL
27 lines
569 B
Markdown
27 lines
569 B
Markdown
---
|
|
name: FindDuplicates
|
|
slug: findduplicates
|
|
sourceRef: find.go#L207
|
|
category: core
|
|
subCategory: find
|
|
playUrl: https://go.dev/play/p/muFgL_XBwoP
|
|
variantHelpers:
|
|
- core#find#findduplicates
|
|
similarHelpers:
|
|
- core#find#findduplicatesby
|
|
- core#slice#uniq
|
|
- core#slice#finduniques
|
|
position: 120
|
|
signatures:
|
|
- "func FindDuplicates[T comparable, Slice ~[]T](collection Slice) Slice"
|
|
---
|
|
|
|
Returns a slice with the first occurrence of each duplicated element in the collection, preserving order.
|
|
|
|
```go
|
|
lo.FindDuplicates([]int{1, 2, 2, 1, 2, 3})
|
|
// []int{1, 2}
|
|
```
|
|
|
|
|