Sobes.tech
Junior — Senior

How does capacity constraint affect the result of the append function

livecode

Task condition

Determine what value will be printed by the program when it runs.

func main() {
    fruit := make([]string, 5)
    fruit[0] = "banana"
    fruit[1] = "cucumber"
    fruit[2] = "grape"
    fruit[3] = "watermelon"
    fruit[4] = "pineapple"

    xs := fruit[1:3:3]
    xs[0] = "apple"
    xs = append(xs, "mango")

    fmt.Println(fruit)
}