Two little blog/tutorials posts.

Jarrett Billingsley kb3ctd2 at
Mon Feb 27 20:21:13 PST 2006

"Alan Knowles" <alan at> wrote in message 
news:du0d5a$5j0$1 at
> I'm sure they are lacking in many ways, but feel free to post 
> comments/corrections ;)

Oh, you poor man!  Writing code like you're still in C!  This is D we're 
talking about here.

int main(char[][] args)
    writefln("Hello World");
    writefln("args.length = ", args.length);

    for (int i = 0; i < args.length; i++)
        // Still a good idea to use the %s, so it doesn't escape the arg 
        writefln("args[", i, "] = '%s'", args[i]);

    return 0;

Or even:

    foreach (uint i, char[] arg; args)
        writefln("args[", i, "] = '%s'", arg);

Also, this isn't valid code:

char[char[]] testarray =
    "one": "1",
    "two": "2"

There are no associative array initializers yet.  In fact, there are no 
non-static array initializers (dumb, I know).  They've been proposed, but 
they don't exist. 

More information about the Digitalmars-d-learn mailing list