typeover
curriculum

Curriculum Foundations Functions & multi-return exercise 3 · mcq

Functions & multi-return

TypeScript expresses "this can fail" by returning a union with null/undefined, throwing, or returning a Result-like object. Go has a strong convention: return a (value, error) tuple where the caller checks the error against nil. Pick the idiomatic Go signature.

TypeScript reference
Pick the idiomatic Go translation

About this theme

Functions look familiar — func name(args) returnType { ... } — with one big new idea: multiple return values. Go functions can return a tuple, and the convention for "this might fail" is to return (result, error). We'll meet error properly in a later module, but the *shape* arrives here.