for (var foo in bar) print(foo);
for (final foo in bar) print(foo);
Is there any difference in performance between these two? Or is the only difference "avoiding accidental reassignments"?
Edit:
prefer_final_locals mentions compiler performing optimizations when final
is used. Will it apply here? dart2js
output matches for the 2 snippets above. Not sure about dart2native
.
final
instead ofvar
matters for optimization for local variables. Even if it mattered, the compiler should be able to easily determine itself whether a local variable is reassigned or not. Additional skepticism: github.com/dart-lang/linter/issues/2103