我想知道,如果在Scala中将Sequence转换为不可变队列有标准和简短的方法吗?
我没有在文档中找到一种神奇的方法.
现在我这样做:
def toQueue[A](s: Seq[A]): Queue[A] = s match {
case x +: xs => x +: toQueue(xs)
case _ => Queue.empty[A]
}
Run Code Online (Sandbox Code Playgroud)
但还有什么更方便的吗?