Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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