Wim, Ahh, I understand now.
Thanks a lot for the explanation, Nestor On Wednesday, February 1, 2017 at 5:05:03 PM UTC-8, Wim Lewis wrote: > > On Feb 1, 2017, at 4:56 PM, Néstor Flórez <rot...@gmail.com <javascript:>> > wrote: > > OK, thanks for the clarification on the size being immutable.(I am trying > to teach myself Go) > > Still I want to know what happens when this statement is executed > sort.Ints(scores[:]) > > - Sort creates a slice > - The slice is sorted > - Sort copies the slice into the array > > Is this what is happening? > > > A slice is basically a reference to a part of an array (a slice of an > array). So when the slice is sorted, the items being manipulated are > actually the items in the underlying array. Think of the sort function as > actually taking a reference to the array and a start and end position > describing what part of the array to sort, and you'll have a clearer idea > why "scores" ends up sorted. A slice is just a small struct containing that > information. > > This page describes the difference between slices and arrays: > https://blog.golang.org/slices > > and has this summary: > > A slice is a data structure describing a contiguous section of an array > stored separately from the slice variable itself. *A slice is not an > array*. A slice *describes* a piece of an array. > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.