-
Notifications
You must be signed in to change notification settings - Fork 72
FAQ
This page should evolve over time, but already be useful now. When more official documentation is available, content can be replaced by links.
-
collection.breakOut
no longer exists - Method
to[C]
was removed -
MapProxy
,SetProxy
no longer exist -
SynchronizedX
no longer exist -
SeqForwarder
no longer exists - Implicit conversions between Scala and Java collections no longer exist (
convert.ImplicitConversions
/ImplicitConversionsToJava
/ImplicitConversionsToScala
) -- NOTE: they are not deprecated in 2.12. -
MutableList
is no longer public -
TreeMap
/TreeSet
/BitSet
: theto
method is now calledrangeTo
-
immutable.Set/Map
: the+
method no longer has an overload accepting multiple values, soSet(1) + (2, 3)
is nowSet(1) + 2 + 3
-
mutable.Set/Map
no longer has a+
method, somutable.Set(1) + 2
is nowmutable.Set(1).clone() += 2
(https://github.com/scala/collection-strawman/issues/375) -
mutable.Set/Map
no longer has anupdated
method, somutable.Map(1 -> 2).updated(1, 3)
is nomutable.Map(1 -> 2).clone() += 1 -> 3
-
Iterable
no longer has asameElements
method, call.iterator()
first -
colleciton.Seq.union
no longer exists, use++
-
collection.Set/Map
no longer have+
methods, so use++
(???) -
collection.Map
no longer has-
or--
methods -
LinearSeq
no longer has a companion-apply, useList()
-
HashSet.remove
now returns anOption[A]
instead of aBoolean
-
Iterable.partition
invokesiterator
twice and assumes it gets two iterators over the same elements. Strict subclasses overridepartition
do perform only a single traversal. -
List.union
no longer exists, use:::
-
Stream.append
is nowStream.lazyAppendAll
, is nowLazyList.lazyAppendAll
Are there new implementations of existing collection types (changes in performance characteristics)?
- Compat library
- Accept some deprecation warnings (?)
- sbt's version-specific source folders if necessary, but should not be
We have plans to change the scala.Seq
alias, https://github.com/scala/collection-strawman/issues/149.
Historical discussion: https://groups.google.com/forum/#!topic/scala-internals/g_-gIWgB8Os
Read the draft document on the design of the Scala 2.13 collections: https://github.com/scalacenter/docs.scala-lang/blob/collection-strawman/_overviews/core/architecture-of-scala-collections.md
You want to add overloads to specialize a transformation operations such that they return a more specific result. Examples are:
-
map
, onStringOps
, when the mapping function returns aChar
, should return aString
(instead of anIndexedSeq
), -
map
, onMap
, when the mapping function returns a pair, should return aMap
(instead of anIterable
), -
map
, onSortedSet
, when an implicitOrdering
is available for the resulting element type, should return aSortedSet
(instead of aSet
).
The following table lists transformation operations that might return a too wide type. You might want to overload these operations to return a more specific type.
Collection | Operations |
---|---|
Iterable |
map , flatMap , collect , scanLeft , scanRight , groupMap , concat , zip , zipAll , unzip
|
Seq |
prepended , appended , prependedAll , appendedAll , padTo , patch
|
immutable.Seq |
updated |
SortedSet |
map , flatMap , collect , zip
|
Map |
map , flatMap , collect , concat
|
immutable.Map |
updated , transform
|
SortedMap |
map , flatMap , collect , concat
|
immutable.SortedMap |
updated |
Examples