Programming-Idioms

History of Idiom 2 > diff from v93 to v94

Edit summary for version 94 :
[D] semicolon is needed on import statement

Version 93

2019-09-27, 16:34:49

Version 94

2019-09-27, 16:41:04

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration
Imports
import std.stdio
Imports
import std.stdio;
Code
foreach(i; 0..10)
  writeln("Hello");
Code
foreach(i; 0..10)
  writeln("Hello");
Comments bubble
use foreach with a numeric range instead of for whenever possible to avoid subtle errors. Also allows nice type inferrence.
Comments bubble
use foreach with a numeric range instead of for whenever possible to avoid subtle errors. Also allows nice type inferrence.