Sobes.tech
Junior — Senior

The effect of the append function on the original slice

livecode

Task condition

Determine what the output of the program will be and find out whether the call to append will modify the original slice c. Also, specify which elements will be in the slice b after executing the code.

package main

import "fmt"

func main() {
    c := []string{"A", "B", "D", "E"}
    b := c[1:2]
    b = append(b, "TT")
    fmt.Println(c) // ?
    fmt.Println(b) // ?
}