Intermediate
Go (Golang)
Q53 / 100
What is the difference between copy() and assignment for slices?
Correct! Well done.
Incorrect.
The correct answer is B) Assignment copies the slice header (shares backing array); copy() copies elements into a pre-allocated destination
B
Correct Answer
Assignment copies the slice header (shares backing array); copy() copies elements into a pre-allocated destination
Explanation
b := a copies the slice header — both share the same backing array. copy(b, a) copies element values; b must be pre-allocated.
Progress
53/100