Sobes.tech
Junior — Senior

How append modifies the base slice and the obtained copies

livecode

Task condition

Determine what output the program will produce. You need to analyze how the append function affects the original slice and what values the variables will have after adding new elements.

package main

import "fmt"

func main() {
    src := make([]int, 0)
    src = append(src, 1)
    src = append(src, 2)
    src = append(src, 3)
    first := append(src, 4)
    second := append(src, 5)
    fmt.Printf("%v %v %v", src, first, second)
}