I would like to create a script in Dart that detects when in the OutputBool2 list there is a 'false' with a 'true' in the next index
I created this script, but it doesn't seem to work:
List OutputIndex2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23];
List OutpuBool2 = [false, false, false, false, false, false, false, true, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false];
for (int j in OutputIndex2.sublist(0, OutputList2.length - 1)) {
print(j);
if (OutputBool2[j] == false && OutputList2[j 1] == true) {
print(FIND!!);
}
}
Can anyone explain to me what I'm doing wrong? Thanks :)
CodePudding user response:
I made this code:
List<bool> OutpuBool2 = [
false,
false,
false,
false,
false,
false,
false,
true,
false,
false,
false,
false,
true,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false
];
for (var i = 0; i < OutpuBool2.length; i ) {
if (OutpuBool2[i] == false) {
if (OutpuBool2[i 1] == true) {
print('There is a false with a true in the next index in index: $i');
}
}
}
and this is the result: There is a false with a true in the next index in index: 6 There is a false with a true in the next index in index: 11
is that what you meant?