yield
关键字在 Dart 中的实际作用是什么?
最佳答案
yield
将值添加到周围 async*
函数的输出流中。类似于 return
,但不会终止函数。
见 https://dart.dev/guides/language/language-tour#generators
Stream asynchronousNaturalsTo(n) async* {
int k = 0;
while (k < n) yield k++;
}
When the yield statement executes, it adds the result of evaluating its expression to the stream. It doesn’t necessarily suspend (though in the current implementations it does).
关于flutter - 'yield' 关键字在 flutter 中有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55776041/