I am trying with https://dartpad.dev/.
I want to execute multiple processes in the if statement as follows.
void main() {
List<dynamic> arrayA = [1, 2, 3];
List<dynamic> arrayB = [1, 2, 5, 6];
arrayB.forEach((m) => {
if (!arrayA.contains(m)) {
print(m);
break;
}
});
}
However, the following error is output when the process of multiple lines is written in the if statement.
Error compiling to JavaScript:
main.dart:6:19:
Error: Expected '}' before this.
print(m);
^
Error: Compilation failed.
What I want to do is following..
(Temporarily, the process you want to execute is "A" (in this case, "print(m);"))
-In the loop, execute the processing "A" when the condition is true
-I want to escape from the loop after executing the first "A".
Then, please tell me what is wrong in the code and how to write it correctly.
Aucun commentaire:
Enregistrer un commentaire