gpt4 book ai didi

Dart 语言支持 async/await 编程风格,还是类似的?

转载 作者:行者123 更新时间:2023-12-04 08:26:24 25 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Async/Await feature in Dart 1.8

(1 个回答)


6年前关闭。




可以用 Dart 语言编写类似的代码吗?

int i;
try {
i = await getResultAsync();
} catch(exception) {
// Do something
}

最佳答案

基本支持已经可用。
https://www.dartlang.org/articles/await-async/更多细节。

main() async {
print(await foo());
try {
print(await fooThrows());
} catch(e) {
print(e);
}
}

foo() async => 42;

fooThrows() async => throw 'Anything';

关于Dart 语言支持 async/await 编程风格,还是类似的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17490888/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com