Alexey Knyazev
2015-10-02 15:08:09 UTC
Why are function parameters treated differently when it was called with
await instead of using '.then'? For example, this code
import 'dart:async';
main() async {
Future foo(int a1, int a2) {
print("from foo: $a1 $a2");
return new Future.value();
}
int a = 0;
await foo(a++, a++);
print("after await foo: $a");
a = 0;
foo(a++, a++).then((_) {
print("after foo.then: $a");
});
}
prints
from foo: 0 0
after await foo: 1
from foo: 0 1
after foo.then: 2
await instead of using '.then'? For example, this code
import 'dart:async';
main() async {
Future foo(int a1, int a2) {
print("from foo: $a1 $a2");
return new Future.value();
}
int a = 0;
await foo(a++, a++);
print("after await foo: $a");
a = 0;
foo(a++, a++).then((_) {
print("after foo.then: $a");
});
}
prints
from foo: 0 0
after await foo: 1
from foo: 0 1
after foo.then: 2
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.