What is Scala's collections library and its main categories?
Answer
Scala has a rich collections library organized into immutable and mutable packages. Immutable collections (default, in scala.collection.immutable): List (linked list), Vector (indexed sequence), Set, Map, LazyList (lazy/infinite sequences). Operations return new collections. Mutable collections (in scala.collection.mutable): ArrayBuffer, ListBuffer, HashMap, HashSet. Modified in place. Common operations work uniformly across all collections: map, filter, flatMap, fold, reduce, zip, partition, groupBy, sorted. Type hierarchy: Traversable → Iterable → Seq/Set/Map. Scala 2.13 simplified the hierarchy. Prefer immutable collections by default — use import scala.collection.mutable explicitly when mutation is needed. The collections API is one of Scala's strongest features for data transformation.