[go-nuts] Re: I want to know the reason behind slices.Clone using append s[:0:0]

2024-09-29 Thread Hikmatulloh Hari Mukti (Hari)
ent-2267179883 > > On Thursday, September 26, 2024 at 8:29:59 PM UTC+8 Hikmatulloh Hari Mukti > (Hari) wrote: > >> Hi gophers, I want to know the reason behind the decision of using >> *append(s[:0:0], >> s...)* over the previous code since the two code return differ

[go-nuts] Re: I want to know the reason behind slices.Clone using append s[:0:0]

2024-09-26 Thread Hikmatulloh Hari Mukti (Hari)
ialization library?). It's user-visible, so it's safest to clone like >>> with like. >>> >>> Apart from that, your issue seems to be: cloning an empty slice with the >>> new code keeps a reference to the original slice backing array, albeit with >&

[go-nuts] I want to know the reason behind slices.Clone using append s[:0:0]

2024-09-26 Thread Hikmatulloh Hari Mukti (Hari)
Hi gophers, I want to know the reason behind the decision of using *append(s[:0:0], s...)* over the previous code since the two code return different slice when dealing slice with zero len. The previous code will return brand new slice with size zero, while the current code return an empty slic