Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing import scala.collection.parallel in Scala 2.13

Tags:

Parallel collections in Scala 2.12 were importable out-of-the-box like so

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

however why in Scala 2.13 package scala.collection.parallel seems to be missing?

like image 683
Mario Galic Avatar asked Jun 11 '19 11:06

Mario Galic


1 Answers

Parallel collections have been moved in Scala 2.13 to separate module scala/scala-parallel-collection

This Scala standard module contains the package scala.collection.parallel, with all of the parallel collections that used to be part of the Scala standard library.

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

thus from 2.13 onwards we need the following dependency

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

and to enable .par extension method import

import scala.collection.parallel.CollectionConverters._

Corresponding scaladoc is also no longer available from 2.13 API docs but instead is published at javadoc.io/doc/org.scala-lang.modules/scala-parallel-collections_2.13.

like image 143
Mario Galic Avatar answered Sep 26 '22 08:09

Mario Galic