Re: Dynamic / resizable array type, and a crash problem

2015-05-15 Thread anonymous via Digitalmars-d-learn
On Thursday, 14 May 2015 at 20:50:05 UTC, ivoras wrote: I'm experimenting to get a feel for the language. Do you have a suggestion about this example code: https://goo.gl/F7LCAg to make it more D-like, idiomatic? Quoting from the code: for (int i = 0; i count; i++) { foreach(i; 0 ..

Re: Dynamic / resizable array type, and a crash problem

2015-05-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 14 May 2015 at 13:26:27 UTC, ivoras wrote: Is it resizable? You can append with the ~= operator and size down by slicing it. Apparently it doesn't even have an insert method: http://dlang.org/phobos/std_array.html . http://dlang.org/phobos/std_array.html#insertInPlace is the

Re: Dynamic / resizable array type, and a crash problem

2015-05-14 Thread ivoras via Digitalmars-d-learn
On Thursday, 14 May 2015 at 12:46:48 UTC, Adam D. Ruppe wrote: I would just use a regular `string[]` array... Is it resizable? Somehow I didn't get that impression from the docs. Apparently it doesn't even have an insert method: http://dlang.org/phobos/std_array.html .

Re: Dynamic / resizable array type, and a crash problem

2015-05-14 Thread Namespace via Digitalmars-d-learn
On Thursday, 14 May 2015 at 13:26:27 UTC, ivoras wrote: On Thursday, 14 May 2015 at 12:46:48 UTC, Adam D. Ruppe wrote: I would just use a regular `string[]` array... Is it resizable? Somehow I didn't get that impression from the docs. Apparently it doesn't even have an insert method:

Dynamic / resizable array type, and a crash problem

2015-05-14 Thread ivoras via Digitalmars-d-learn
What is the recommended dynamic array type in D? So far I found Array (specifically Array!string, as I need a dynamic array of strings), but my example program crashes: https://gist.github.com/ivoras/2d7737c214c3dc937c28 The crash is at line 20:

Re: Dynamic / resizable array type, and a crash problem

2015-05-14 Thread anonymous via Digitalmars-d-learn
On Thursday, 14 May 2015 at 12:42:01 UTC, ivoras wrote: https://gist.github.com/ivoras/2d7737c214c3dc937c28 The crash is at line 20: core.exception.AssertError@/usr/include/dmd/phobos/std/container/array.d(334): [...] This is on DMD32 D Compiler v2.067.1 Seems to be fixed in git head.

Re: Dynamic / resizable array type, and a crash problem

2015-05-14 Thread Adam D. Ruppe via Digitalmars-d-learn
I would just use a regular `string[]` array...

Re: Dynamic / resizable array type, and a crash problem

2015-05-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 14 May 2015 at 20:03:16 UTC, ivoras wrote: Where would I look for documentation on the ~= operator? http://dlang.org/arrays.html under the heading array concatenation What would be the difference between Array!string and string[] ? Array!string takes ownership of its own

Re: Dynamic / resizable array type, and a crash problem

2015-05-14 Thread ivoras via Digitalmars-d-learn
On Thursday, 14 May 2015 at 20:32:28 UTC, rumbu wrote: On Thursday, 14 May 2015 at 20:03:16 UTC, ivoras wrote: What would be the difference between Array!string and string[] ? std.array is used to manipulate or create built-in arrays from various sources (ranges). For basic needs, you

Re: Dynamic / resizable array type, and a crash problem

2015-05-14 Thread ivoras via Digitalmars-d-learn
On Thursday, 14 May 2015 at 13:50:17 UTC, Adam D. Ruppe wrote: On Thursday, 14 May 2015 at 13:26:27 UTC, ivoras wrote: Is it resizable? You can append with the ~= operator and size down by slicing it. Apparently it doesn't even have an insert method: http://dlang.org/phobos/std_array.html .

Re: Dynamic / resizable array type, and a crash problem

2015-05-14 Thread rumbu via Digitalmars-d-learn
On Thursday, 14 May 2015 at 20:03:16 UTC, ivoras wrote: What would be the difference between Array!string and string[] ? std.array is used to manipulate or create built-in arrays from various sources (ranges). For basic needs, you can safely use built-in arrays: