Programming-Idioms

History of Idiom 2 > diff from v5 to v6

Edit summary for version 6 :
β†·

Version 5

2015-08-18, 15:04:34

Version 6

2015-08-20, 15:13:26

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Imports
std.stdio
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.