Thursday 2 May 2019

Go Language: Arrays vs slices


a.   Arrays are fixed in size. If you create an array of size 6, then it can able to store exactly 6 elements. You can’t store more than 6 elements in the array, but slices can be resized on demand.
b.   Slices are built on top of arrays. If you are changing any value of the slice, then it is going to change the value of underlying array and vice versa.
c.    Arrays are passed by value, whereas slices are passed by reference.




Previous                                                 Next                                                 Home

No comments:

Post a Comment