On Mon, 2017-01-09 at 15:12 -0800, Tomi Häsä wrote:
> Is this the correct way of resetting a slice? I mean do I always need
> to
> use make to reset a slice?
>
> // initialize slice
>
> onearea Area = Area{}
>
> group []Area = make( []Area, 0, MAX )
>
> // add stuff to slice
>
> group = append( group, onearea )
>
> // reset slice
>
> group = make( []Area, 0, MAX )
group = group[:0]
> Using nil to reset a slice doesn't seem to be wise as the capacity
> does not
> stay with MAX, but it will decrease to 2 in my program.
>
> group = nil
>
> Full code here: https://github.com/tomihasa/unicodetest
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.