1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 21:02:27 +08:00

docs: add doc for UniqueBy function

This commit is contained in:
dudaodong
2022-06-22 15:45:29 +08:00
parent ae0facd32d
commit 5dbdbcd651
2 changed files with 53 additions and 2 deletions

View File

@@ -998,7 +998,33 @@ func main() {
### <span id="Union">Unique</span>
### <span id="UniqueBy">UniqueBy</span>
<p>Call iteratee func with every item of slice, then remove duplicated.</p>
<b>Signature:</b>
```go
func UniqueBy(slice, iteratee interface{}) interface{}
```
<b>Example:</b>
```go
import (
"fmt"
"github.com/duke-git/lancet/slice"
)
func main() {
res := slice.UniqueBy([]int{1, 2, 3, 4, 5, 6}, func(val int) int {
return val % 4
})
fmt.Println(res) //[]int{1, 2, 3, 0}
}
```
### <span id="Union">Union</span>
<p>Creates a slice of unique values, in order, from all given slices. using == for equality comparisons.</p>
<b>Signature:</b>

View File

@@ -998,7 +998,32 @@ func main() {
### <span id="Union">Unique</span>
### <span id="UniqueBy">UniqueBy</span>
<p>对切片的每个项目调用iteratee函数然后删除重复的</p>
<b>函数签名:</b>
```go
func UniqueBy(slice, iteratee interface{}) interface{}
```
<b>例子:</b>
```go
import (
"fmt"
"github.com/duke-git/lancet/slice"
)
func main() {
res := slice.UniqueBy([]int{1, 2, 3, 4, 5, 6}, func(val int) int {
return val % 4
})
fmt.Println(res) //[]int{1, 2, 3, 0}
}
```
### <span id="Union">Union</span>
<p>从所有给定的切片按顺序创建一个唯一值切片。 使用 == 进行相等比较。</p>
<b>函数签名:</b>