Thx Ian, So basically it's because we allocate new array in version without cap, right? Because it outgrows current cap. So pointer from slice b is pointing to new slice (i've checked they have different addresses for first element) different from a. And in version with cap=10 we still append to the same array as there is no relocation, that's why we have same elements in both slices (they point to the same array). Right?
W dniu niedziela, 3 lipca 2016 15:59:33 UTC+2 użytkownik Ian Lance Taylor napisał: > > On Sun, Jul 3, 2016 at 4:27 AM, <rog...@gmail.com <javascript:>> wrote: > > Can anyone ELI5 it to me, please ? Why if we remove cap result is > different > > ? I don't understand that. > > https://blog.golang.org/slices > > Ian > -- 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.