- Learning Functional Programming in Go
- Lex Sheehan
- 71字
- 2021-07-02 23:13:34
Contains
Let's consider another common collection operation: contains.
In Go, lists of things are often stored in a slice. Wouldn't it be nice if Go provided a contains method to tell us whether the item we are looking for is contained in the slice? Since there is no generic contains method for working with lists of items in Go, let's implement one to iterate over a collection of car objects.