Learning Functional Programming in Go
上QQ阅读APP看书,第一时间看更新

Terminal functions

Terminal functions are eagerly executed. They execute immediately and once executed, they execute all the previous intermediate, lazy functions in the call chain. Terminal functions either return a single value or produce a side effect. The reduce example, we saw earlier, returns a single value: 1. The ForEach function does not return a value but can produce a side effect, such as printing out each item. The Collect, Join, and GroupBy functions group items in a collection.