Programming-Idioms

History of Idiom 43 > diff from v11 to v12

Edit summary for version 12 :

Version 11

2015-08-20, 10:38:32

Version 12

2015-08-20, 15:33:24

Idiom #43 Break outer loop

Look for a negative value v in 2D integer matrix m. Print it and stop searching.

Idiom #43 Break outer loop

Look for a negative value v in 2D integer matrix m. Print it and stop searching.

Imports
import std.writeln;
Code
outer:
foreach (i; 0 .. m.length)
{
	foreach (j; 0 .. m[i].length)
	{
		if (m[i][j] < 0)
		{
			writeln(m[i][j]);
			break outer;
		}
	}
}
Comments bubble
D has labeled break and continue statements.