Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Add UniqMap #526

Open
nicklaus-dev opened this issue Aug 29, 2024 · 0 comments
Open

Proposal: Add UniqMap #526

nicklaus-dev opened this issue Aug 29, 2024 · 0 comments

Comments

@nicklaus-dev
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant