November 2017
Intermediate to advanced
670 pages
17h 35m
English
Use of expressions (rather than statements) means that in FP, we pass a value to a function that typically transforms it in some way and then returns a new value. Since FP functions have no side effects, an FP function that does not return a value is useless and a sign of code smell.
In Chapter 1, Pure Functional Programming in Go, we saw that imperative programming focuses on the step-by-step mechanics of how a program operates, whereas in declarative programming, we declare what we want the results to be.
Here's an example of imperative programming:
var found boolcar_to_look_for := "Blazer"cars := []string{"Accord", "IS250", "Blazer" }for _, car := range cars { if car == car_to_look_for { found = true; }}fmt.Printf(