Omit creates a new slice with the arguments omitted from the list.
(a []T, omits ...T)
| 45 | |
| 46 | // Omit creates a new slice with the arguments omitted from the list. |
| 47 | func Omit[T comparable](a []T, omits ...T) []T { |
| 48 | tmp := make([]T, 0, len(a)) |
| 49 | for _, v := range a { |
| 50 | if Contains(omits, v) { |
| 51 | continue |
| 52 | } |
| 53 | tmp = append(tmp, v) |
| 54 | } |
| 55 | return tmp |
| 56 | } |
| 57 | |
| 58 | // SameElements returns true if the 2 lists have the same elements in any |
| 59 | // order. |