When you pass a slice to a function, the header is copied but the underlying array is shared:
func modify(s []int) {
s[0] = 99 // changes original!
}
nums := []int{1, 2, 3}
modify(nums)
fmt.Println(nums[0]) // 99
The function can modify elements, and those changes persist. But if the function appends and causes reallocation, the caller won't see new elements. Return the modified slice to handle this.