November 2018
Intermediate to advanced
346 pages
8h 12m
English
While the ATM example was clear, it was a system, and so you may be wondering how that could possibly apply to low-level concepts, such as functions. Let's look at an example:
// PetFetcher searches the data store for pets whose name matches// the search string.// Limit is optional (default is 100). Offset is optional (default 0).// sortBy is optional (default name). sortAscending is optionalfunc PetFetcher(search string, limit int, offset int, sortBy string, sortAscending bool) []Pet { return []Pet{}}
That probably looks OK, right? The problem is that most of the usage looks like the following:
results := PetFetcher("Fido", 0, 0, "", true)
As you can see, most of the time we don't need all of those return values, ...
Read now
Unlock full access