Back to Lo

Core Withoutby

docs/data/core-withoutby.md

1.53.0313 B
Original Source

Filters a slice by excluding elements whose extracted keys match any in the exclude list.

go
type User struct {
  ID int
  Name string
}

users := []User{
  {1, "Alice"},
  {2, "Bob"},
  {3, "Charlie"},
}

filtered := lo.WithoutBy(users, func(u User) int {
    return u.ID
}, 2, 3)
// []User{{1, "Alice"}}