diff --git a/dart/Label with Break.dart b/dart/Label with Break.dart new file mode 100644 index 0000000..aac6459 --- /dev/null +++ b/dart/Label with Break.dart @@ -0,0 +1,23 @@ + + +void main() { + outerloop: // This is the label name + + for (var i = 0; i < 5; i++) { + print("Innerloop: ${i}"); + innerloop: + + for (var j = 0; j < 5; j++) { + if (j > 3 ) break ; + + // Quit the innermost loop + if (i == 2) break innerloop; + + // Do the same thing + if (i == 4) break outerloop; + + // Quit the outer loop + print("Innerloop: ${j}"); + } + } +} diff --git a/dart/Label with continue.dart b/dart/Label with continue.dart new file mode 100644 index 0000000..bdc1558 --- /dev/null +++ b/dart/Label with continue.dart @@ -0,0 +1,14 @@ +void main() { + outerloop: // This is the label name + + for (var i = 0; i < 3; i++) { + print("Outerloop:${i}"); + + for (var j = 0; j < 5; j++) { + if (j == 3){ + continue outerloop; + } + print("Innerloop:${j}"); + } + } +}