On Saturday, 19 October 2013 at 12:08:49 UTC, Daniel Davidson wrote:
On Saturday, 19 October 2013 at 04:52:31 UTC, Jesse Phillips wrote:
Do to the recent slices discussion I did some investigation on what is different in Go. Thus, created this

http://he-the-great.livejournal.com/48672.html

It starts with:
    int[] original;
    original.reserve(5);
    writeln("orig cap: ", original.capacity); // 7
    writeln("orig len: ", original.length); // 0

Further down says: "But to discuss behavior we'll need some elements."

and immediately proceeds with code accessing original where no data has been added:

    auto slice = original[1..$];
    writeln("slice cap: ", slice.capacity); // 6
    writeln("slice len: ", slice.length); // 2
    original[0]++;
    slice[0]++;
    slice[1]++;
    writeln("orig: ", original); // [1, 2, 3]

I don't know where the [1,2,3] comes from. The first original[1..$] will crash. Maybe you are forgetting the actual initialization of original with data?

Ahh ok. You may want to point to the fact that you are referring to a larger and complete code file linked at the bottom of the page.

Reply via email to