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?

Thanks

On Wednesday, February 1, 2017 at 4:30:37 PM UTC-8, Michael Jones wrote:
>
> array contents are not immutable, just their size.
>
> On Wed, Feb 1, 2017 at 4:13 PM, Néstor Flórez <rot...@gmail.com 
> <javascript:>> wrote:
>
>> The below code sorts an array but it does it  an by creating a slice, 
>> correct?
>> What happened to the original array?
>> Arrays are inmutable
>>
>>
>> --------------------------------------------------------------------------------------------------------------
>> package main
>> import ("fmt"
>>            "sort")
>>
>> func main(){
>>   var scores [10]int                           // creates array scores
>>   scores[0]= 99                                // sets 1st element to 99
>>   fmt.Println("SCORES \n", scores)   //print the unsorted array
>>
>>   sort.Ints(scores[:])                         //creates a slice "scores"
>>   fmt.Println("\n", scores)                  //print the slice "scores"
>> }                                                     //what happened to 
>> the array scores?
>>
>> ------------------------------------------------------------------------------------------------------------
>>  [99 0 0 0 0 0 0 0 0 0]
>>
>>  [0 0 0 0 0 0 0 0 0 99]
>>
>> -------------------------------------------------------------------------------------------------------------
>> Thanks
>>
>> -- 
>> 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...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Michael T. Jones
> michae...@gmail.com <javascript:>
>

-- 
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.

Reply via email to