- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
方法说明:
Given a list of futures
fs
, returns the future holding the list of values of all the futures fromfs
. The returned future is completed only once all of the futures infs
have been completed. The values in the list are in the same order as corresponding futuresfs
. If any of the futuresfs
fails, the resulting future also fails.
implicit class FutureCompanionOps[T](val f: Future.type) extends AnyVal {
/***
//Some others method
***/
def all[T](fs: List[Future[T]]): Future[List[T]] = async {
var fsVar = fs;
val l = List()
while(fsVar.nonEmpty){
await{fsVar.head} :: l
fsVar = fsVar.tail
}
l
}
}
def all[T](fs: List[Future[T]]): Future[List[T]] = async {
:
implementation restriction: nested class is not allowed in value class This restriction is planned to be removed in subsequent releases.
最佳答案
从常见问题解答:
Scala 异步功能即将发布第一个版本,部分处于实验阶段。
作为在值类中使用 Scala Async 的解决方法,请考虑使用以下技巧将异步调用移到值类之外:
class FutureOps[T](f: Future[T]) extends AnyVal {
def foo: Future[T] = fooImpl(f)
}
def fooImpl(f: Future[T]) = async {
val x = await { f }
throw new Exception
}
map
,
flatMap
,
continueWith
和他们的其他 friend 。
关于scala - "implementation restriction: nested class is not allowed in value class This restriction is planned to be removed in subsequent releases.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20252687/
我是一名优秀的程序员,十分优秀!