Programming-Idioms

History of Idiom 43 > diff from v12 to v13

Edit summary for version 13 :

Version 12

2015-08-20, 15:33:24

Version 13

2015-08-21, 16:52:29

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.

Code
OUTER: for (var i = 0; i < m.length; i++) {
  for (var j = 0; j < m[i].length; j++) {
    if (m[i][j] < 0) {
      print("Negative value found at $i,$j: ${m[i][j]}");
      break OUTER;
    }
  }
}
Demo URL
https://dartpad.dartlang.org/9cdbc88c899c75518d1e