Talk:D (programming language): Difference between revisions

Content deleted Content added
SeeSchloss (talk | contribs)
more D-specific example ?
indexed foreach
Line 9:
Wouldn't it be slightly better to use a D-specific statement in the example like foreach instead of for ?
 
The problem is that it won't have exactly the same output as the current example (you can't print the number of the argument unless you add an ''i'' variable somewhere and increment it each time, but that doesn't look very clean) :
 
: D allows foreach loops to be indexed, so there's no problem at all. -- [[User:Smjg|Smjg]] 22:36, 3 Jul 2004 (UTC)
 
==Example==
Line 17 ⟶ 19:
{
printf("hello world\n");
foreach (int i, char[] arg ; args)
printf("args[%d] = '%.*s'\n", i, arg);
return 0;
}