24 Sets

  • Sets are constructed simply using Set(element1, element2, ...)
  • The Set can contain mixed types, but the final type of the elements will be the lowest common denominator
  • The default Set is Predef.Set which points to scala.collection.immutable.Set
  • As it currently stands, Set implementation up to size of 4 has a specific class Set1, Set2, Set3, Set4, beyond that, it uses an immutable HashSet
  • You can’t have duplicate values, adding a value that already exists overwrites the value
  • Order of iteration is not guaranteed to be consistent

See Also opens in new page

Code editor is using Scalakata.com written by Guillaume Massé