array contents are not immutable, just their size.

On Wed, Feb 1, 2017 at 4:13 PM, Néstor Flórez <rot...@gmail.com> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Michael T. Jones
michael.jo...@gmail.com

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