Grokking Go
0% completed
Array As a Function Parameter
In Go, arrays can be passed as parameters to functions, allowing functions to process multiple values at once. However, since arrays in Go are values (not references), they are passed by value, meaning a copy of the array is created inside the function. This means modifications inside the function do not affect the original array.
If you want a function to modify an array directly, you need to pass a pointer (we will learn about it in upcoming chapters) to the array or use a slice instead.
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%