Sobes.tech
Junior — Senior

Determining the output when using the append function

livecode

Task condition

It is necessary to understand what data will appear in the console after executing the program, considering the features of the append function and how slices interact during assignment.

func main() {
  var foo []int
  var bar []int

  foo = append(foo, 1)
  foo = append(foo, 2)
  foo = append(foo, 3)
  bar = append(foo, 4)
  foo = append(foo, 5)

  fmt.Println(foo, bar)
}