STEP 1
A function is a named recipe: it receives input, does one focused job, and returns an output.
Values, Types & Pure Functions
Go Syntax & The Type System
Every API, calculation, and concurrent worker starts with values flowing through functions. Clear types make those flows predictable before a bug reaches production.
STEP 1
A function is a named recipe: it receives input, does one focused job, and returns an output.
STEP 2
An accumulator starts with the identity value for an operation. For addition, that value is 0, so an empty list naturally returns 0.
STEP 3
A pure function does not change its input or depend on hidden state. That makes it easier to test, reuse, and parallelise later in Go.
A safe sum has an honest starting value
What should a sum function return for an empty list?
Next: Phase 2 Hands-On Drill
Solve the coding challenge in the in-browser IDE with live visible and hidden specification tests.