Logo

Programming-Idioms

History of Idiom 2 > diff from v6 to v7

Edit summary for version 7 by :

Version 6

2015-08-20, 15:13:26

Version 7

2015-08-20, 15:14:12

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
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.