Re: [go-nuts] Is this a bug or am I missing something?

2017-12-19 Thread Tamás Gulácsi
When you append to a slice with the append function, it just assigns the value to the len.th slot and increments len. This is only possible, if the backing array is big enough. This backing array capacity is the slice's capacity, retrieved by cap. If the capacity is not enough, a new, bigger

Re: [go-nuts] Is this a bug or am I missing something?

2017-12-19 Thread Sasan Rose
Hi Jesse Thank you very much. I guess that happens when you come to Go with a PHP background. I still have one question, why does it happen always on that iteration? Not the previous iterations? On Tuesday, December 19, 2017 at 4:32:09 PM UTC+11, Jesse McNelis wrote: > > On Tue, Dec 19, 2017

Re: [go-nuts] Is this a bug or am I missing something?

2017-12-18 Thread Jesse McNelis
On Tue, Dec 19, 2017 at 4:10 PM, Sasan Rose wrote: > Hi Jess > > Apologies for my bad example. Please kindly see my reply to Dave's post. > Thanks I fixed your example so that the slice called 'combination' isn't shared with every slice in every iteration of the loop.

Re: [go-nuts] Is this a bug or am I missing something?

2017-12-18 Thread Sasan Rose
Hi Jess Apologies for my bad example. Please kindly see my reply to Dave's post. Thanks On Tuesday, December 19, 2017 at 2:43:50 PM UTC+11, Jesse McNelis wrote: > > On Tue, Dec 19, 2017 at 8:54 AM, Sasan Rose > wrote: > > Please take a look at

Re: [go-nuts] Is this a bug or am I missing something?

2017-12-18 Thread Jesse McNelis
On Tue, Dec 19, 2017 at 8:54 AM, Sasan Rose wrote: > Please take a look at https://play.golang.org/p/BL4LUGk-lH solutionNew = make([]int, 0) solutionNew = append(solution, 2) Is a strange thing to do, you create a new slice using make([]int, 0) and then never use it.