Search code examples
scalaparallel-processingparallel-collections

Will Scala's parallel collections guarantee ordering?


If I have this:

val a = Array(...)

and I write

a.par.map(e => someFunc(e))

Will the resulting collection be in the same order as the non-parallel collection?


Solution

  • Yes, but the function itself is executed without any particular order.

    List(1,2,3).par foreach print // could print out 213