|
Bruno Albuquerque |
at Apr 1, 2015 at 5:54 pm
|
⇧ |
| |
And, BTW, thats why you have to do it like you did:
slice = append(...)
The returned slice might be a new slice that is different from the original
you had.
Em qua, 1 de abr de 2015 às 14:53, Bruno Albuquerque <
bga@bug-br.org.br>
escreveu:
Append creates a new slice when it needs to grown it being capacity and
copies the elements of the original slice to the new one.
Em qua, 1 de abr de 2015 às 14:49, <vlyamtsev@gmail.com> escreveu:From golang book (http://www.golang-book.com/6/index.htm):
"A slice cannot be grown beyond its capacity. Attempting to do so will
cause a runtime panic, just as when indexing outside the bounds of a slice
or array. Similarly, slices cannot be re-sliced below zero to access
earlier elements in the array"
Than, can someone explain how's the following work?
//make array af len=0, capacity=0
slice := make([]string, 0)
....
slice = append(slice, "one")
--
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+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout. --
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+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.