All lessons

Power Tools: Multiple Returns, Closures & Slices

10 min · Go

Return more than one value, write inline function literals, and build your own map/filter over a slice.

Go · Power Tools: Multiple Returns, Closures & Slices0/5 cleared

Enemy 1 of 5

A Go function can return more than one value — list the types in ( ) and return them comma-separated. := unpacks both into new variables at once.

You
Syntax Skeleton

Loading editor...

Ln 1, Col 1Spaces: 4
Sign up to fightTarget output: 3 2