Hello and welcome to Go! It will all make sense after reading this: https://blog.golang.org/go-slices-usage-and-internals
I leave you to find the solution once you have read the article :). Hint: It indeed has to do with the backing array of the slice. In step1 you are creating a new slice for dst but it shares the same array as src. Le dimanche 20 novembre 2016 06:56:18 UTC+1, Bogdan Katyński a écrit : > > Hello Group, > > I'm very new to GoLang and this is my first post to the group so first of > all hello all :) > > I just came across a strange thing which I'm failing to understand: > https://play.golang.org/p/BOCsJqIw63 > > I don't understand why in Step2, the src slice is changed to [1 2 3 4 1 6 > 7 8] > > I suppose it has something to do with the "underlying" array that is > backing both src and dst slices but why doesn't src change in Step1 and > Step3 only in Step2? > > For more context: I'm working on a naive solution to this task: > https://www.hackerrank.com/challenges/array-and-simple-queries > > All help appreciated, > Bogdan > > -- 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.