- Learning Functional Programming in Go
- Lex Sheehan
- 37字
- 2021-07-02 23:13:41
Chaining functions
Now that we have the hang of it, let's chain a few filters together:
PrintCars("Foreign, Numeric, Toyota",
cars.Filter(ByForeign()).
Filter(ByHasNumber()).
Filter(ByMake("Toyota")))
You will see the following output:
Foreign, Numeric, Toyota
-----------------------
car: Toyota 86
car: Toyota RAV4