×

go · level 1 · unit 2 · lesson 1

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

A is a box with a name on it.

A variable is a box with a label. You put a inside, write a name on the label, and from then on you use the name to get the value back.

pet := "Rex" makes a new box called pet and puts the value "Rex" inside. Making a new box is called declaring it. The longer way, var pet = "Rex", does the same job.

Go is tidy about boxes. one and never use it, and Go refuses to run, saying it is declared but not used. Every box needs a job.

package main
import "fmt"
func main() {
	pet := "Rex"
	var snack = "biscuits"
	fmt.Println(pet)
	fmt.Println(snack)
}

Read := as "make a new box and put this in it".