-
-
Notifications
You must be signed in to change notification settings - Fork 897
Closed
Description
Think about this scenario:
func main() {
type User struct {
Name string
Age int
}
// find unique names of users
users := []User{{Name:"Alice",Age: 10},{Name:"Alice",Age: 12},{Name:"Bob",Age: 13}}
names := lo.Map(users,func(u User, index int) string {
return u.Name
})
names = lo.Uniq(names)
fmt.Printf("%v\n", names) // [Alice Bob]
}
To find unique names, I need use Map
and Uniq
helpers. For this scenario, I suppose to add UniqMap
helper.
shuqingzai
Metadata
Metadata
Assignees
Labels
No labels