November 2017
Intermediate to advanced
670 pages
17h 35m
English
In the last chapter, we discussed some of the benefits of generics:
Given the following type definitions:
type Car struct { Make, Model string Price Dollars}type Truck struct { Make, Model string BedSize int Price Dollars}price := func (c T) Dollars { return c.Price}
Instead of writing both of these:
type CarSlice []Carfunc (rcv CarSlice) SumDollars(fn func(Car) Dollars) (result Dollars) { for _, v := range rcv ...