Quiz

November 22, 2023

Today’s quiz day. Tomorrow I’ll provide the answer as we continue with the section of the spec that explains today’s code.

Consider the following program. What is its output?

package main

import "fmt"

func main() {
	a := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
	s := a[2:5]
	s2 := s[5:7]

	fmt.Println(s2)
}
  1. [6 7]
  2. [8 9]
  3. A runtime panic
  4. A compilation error

Share this

Direct to your inbox, daily. I respect your privacy .

Unsure? Browse the archive .