-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
Let's suppose I need to get all elements from A that don't appear in B slice (difference), but comparing only the name.
package main
import (
"fmt"
"github.com/wesovilabs/koazee"
)
type product struct {
code int
name string
}
var fruits1 = []*product{
{code: 9, name: "apple"},
{code: 4, name: "orange"},
{code: 12, name: "lemon"},
}
var fruits2 = []*product{
{code: 1000, name: "apple"}, // The code 1000 is intentional!! I need to compare only by name
}
func main() {
stream := koazee.StreamOf(fruits1)
// ??
stream.ForEach(func(p *product) {
fmt.Printf("%d: \"%s\"\n", p.code, p.name)
}).Do()
}
Should print
4: "orange"
12: "lemon
I'm trying to figure out a good way to do that using koazee.
Metadata
Metadata
Assignees
Labels
No labels