gpt4 book ai didi

scala - Scala 2.13 中缺少 import scala.collection.parallel

转载 作者:行者123 更新时间:2023-12-01 18:59:14 26 4
gpt4 key购买 nike

Parallel collections在 Scala 2.12 中可以像这样开箱即用地导入

import scala.collection.parallel.immutable.ParVector
val pv = new ParVector[Int]

但是为什么在 Scala 2.13 中,scala.collection.parallel 包似乎丢失了?

最佳答案

并行集合已在 Scala 2.13 中移至单独的模块 scala/scala-parallel-collection

This Scala standard module contains the packagescala.collection.parallel, with all of the parallel collections thatused to be part of the Scala standard library.

For Scala 2.13, this module is a separate JAR that can be omitted fromprojects that do not use parallel collections.

因此从 2.13 开始我们需要以下依赖

libraryDependencies += "org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.0"

并启用.par扩展方法导入

import scala.collection.parallel.CollectionConverters._

2.13 API docs 也不再提供相应的 scaladoc而是发布在 javadoc.io/doc/org.scala-lang.modules/scala-parallel-collections_2.13 .

关于scala - Scala 2.13 中缺少 import scala.collection.parallel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56542568/

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