DMD 0.167 release
Chris Nicholson-Sauls
ibisbasenji at gmail.com
Tue Sep 19 05:47:37 PDT 2006
Serg Kovrov wrote:
> I believe there are some issues with array literals right now, and I am
> sure they will be fixed.
>
> Meantime, how this array literals should be used? there is not much
> example code in docs.
>
> int[] i = [1, 2, 3];
This is the one, except the static initializor checks have not been culled yet, so it
doesn't compile. (This is a bug.) For now, you would do something like this:
int[] i; i = [1, 2, 3];
> or
> int[] i = new [1, 2, 3];
> or
> int[] i = new int[1, 2, 3];
> Can it be used with auto i = [1, 2, 3] ?
>
> How about array of stings?like:
> char[][] s = ["one", "two", "three"];
Just like this, once the static-init-chk is culled.
> The only syntax i managed to compile is
> int[] i = new int[1, 2, 3];
> but when i try to print it it produces "[0,0,0]"
>
> Definitely a bug. But before report bugs I'd like to know how it
> actually should works.
>
Try compiling/running the following:
# import std .stdio ;
#
# void main () {
# writefln([1, 2, 3]);
# writefln(["foo", "bar"]);
# }
-- Chris Nicholson-Sauls
More information about the Digitalmars-d-announce
mailing list