...

/

Structs, Collections and Higher-Order Functions

Structs, Collections and Higher-Order Functions

This lesson is an implementation of the example that covers the concepts of structs, interfaces, and higher-order functions studied so far.

We'll cover the following...

Often, when you have a struct in your application, you also need a collection of (pointers to) objects of that struct, like:

type Any interface{}

type Car struct {
  Model string
  Manufacturer string
  BuildYear int
  // ...
}

type Cars []*Car

We can then use the fact that higher-order functions can be arguments to other functions when defining the needed functionality, e.g.:

  1. When defining a general Process() function, which itself takes a function f which operates on every car:
// Process all cars with the given
...