On Tue, Sep 18, 2012 at 9:22 PM, bryanturley <
bryan...@gmail.com> wrote:
>
> In reality slices aren't meant to be deleted from, if you are going to do
> frequent deletions from a (long) list you should probably used some form of
> linked list.
> Though that might be overkill for simple array-like data which is why i do
> use similar slice tricks myself.
Almost every time I have seen people using container/List or pretty
much container/*, it would have been better to use slices or maps or
chans or some other built in type, or building your own datastructure.
Go is like Java or C++, is much more like C, learn to use what the
language gives and usually you will find a clean, simple and efficient
solution.
Uriel
> On Tuesday, September 18, 2012 2:04:38 PM UTC-5, Jan Mercl wrote:
>>
>> On Tue, Sep 18, 2012 at 8:49 PM, Job van der Zwan
>> <
j.l.van...@gmail.com> wrote:
>> > So, given these two options:
>> >
>> > s = s[:i+copy(s[i:], s[i+1:])]
>> >
>> > slice = append(slice[:i], slice[i+1:]...)
>> >
>> > Am I correct in understanding the latter creates a new slice, whereas
>> > the
>> > former overwrites the original?
>>
>> No:
http://play.golang.org/p/iqwKS8jd2C
>>
>> Longer version:
>> - Yes. Both statements overwrite LHS with RHS which LSH is part of
>> (slice really is a value type).
>> - No. Both statements reuse the existing slice backing storage array
>> as the len is (only) shrinking (and cap is not affected at all).
>>
>> -j
>
> --
>
>