November 2017
Intermediate to advanced
670 pages
17h 35m
English
In the types.go file, we see its definition:
FilterFunc func(string) bool
Looking back at the line in main.go, we see that we use the ByMake filter function:
PrintCars("ByMake - Honda", cars.Filter(ByMake("Honda")))
The ByMake function is defined in the cars.go file:
func ByMake(make string) FilterFunc { return func(car string) bool { return s.Contains(car, make) }}
The ByMake function is a HOF because it returns a function. Recall that Filter is a HOF because it accepts a function. In this case, ByMake is that function, fn, as we will see in the next section.