If I use for-in
loop in dart on some List
, are the iterations guaranteed to be in the correct order? e.g. Does the following code
List bars = getSomeListOfBars();
for(bar in bars){
foo(bar);
}
in the exact same way as the following?
List bars = getSomeListOfBars();
for(int i=0;i<bars.length;i++){
foo(bar[i]);
}
I have not found dart
specific explanation anywhere, thank you.
If you use for(x in y)
with a collection that guarantees the iteration order, then for(x in y)
is guaranteed to iterate in this order. If the collection itself doesn't guarantee the order, then of course for(x in y)
doesn't as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With