Color theme
0 day streak0 XPP1
GoLearn mode
MISSION 1 OF 1

Check the museum registry

0 XP earned
Go track: IntermediateMission: IntermediateMapsPresence checksMultiple assignment
Before you start this intermediate track

Functions and typed collections. Work with slices, map lookups, and multiple return values.

Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.

x
0 / 2 challenges
LEARN THE CONCEPT

Understand it, then try it.

A museum map connects hall names to exhibit counts. A stored count of zero does not mean the hall is missing. Go can return both the value and a presence flag from a map lookup. A missing integer entry returns zero, while the second result tells you whether that key actually exists.

main.go
package mainimport "fmt"func main() {    halls := map[string]int{"east": 0, "west": 2}    count, found := halls["east"]    missing, known := halls["roof"]    fmt.Printf("%d %t | %d %t\n", count, found, missing, known)}

Each mission is a complete independent Go program. Save it as main.go and run go run main.go with Go 1.18 or later. Only the standard fmt package is used.

Track the values line by line. Predict the result before running this example in your own editor.