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

Adding _.uniqBy() function #142

Merged
merged 1 commit into from
Mar 9, 2022
Merged

Adding _.uniqBy() function #142

merged 1 commit into from
Mar 9, 2022

Conversation

samber
Copy link
Contributor

@samber samber commented Feb 24, 2022

Pretty useful for matching by a struct attribute.

Usage:

    funk.UniqBy([]int{0, 1, 1, 2, 3, 0, 0, 12}, func(nbr int) int {
		return nbr % 3
	}) // []int{0, 1, 2}

    foo1 := Foo{
        ID: 42,
        FirstName: "Bob",
    }
    foo2 := Foo{
        ID: 42,
        FirstName: "Bob",
    }
    funk.UniqBy([]Foo{foo1, foo2}, func(f Foo) int {
		return f.ID
	}) // []Foo{ Foo{ID: 42, Firstname: "Bob"} }

A new release would be appreciated. 🙏

@thoas
Copy link
Owner

thoas commented Mar 3, 2022

Hi @samber,

Thank you :)

I will take a look at your PR this week-end.

@thoas thoas merged commit 38b2794 into thoas:master Mar 9, 2022
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

Successfully merging this pull request may close these issues.

2 participants