continue
keywordThe continue
keyword breaks one loop iteration when a certain condition is satisfied.
In a loop, the continue
keyword can be used to skip the current execution of the loop block.
The following code shows how to implement the continue
keyword in Dart:
// main() drivevoid main() {// create a listvar myList = ['d', 'a', 'r', 't'];// using for loop to iterate through the listfor(int i=0;i<myList.length;i++){// checks the index that has the value aif(myList[i] == 'a')continue; // skips the indexprint(myList[i]);}}
main()
function.myList
.for
loop. We use an if
statement within the for
loop to check the index with the value a
. If the condition is satisfied, the continue
statement will skip the current execution. Finally, the result is displayed.