Sets can be checked for member existence:
Sets contain distinct values:
Sets can be added to easily:
Two sets can be intersected easily:
Two sets can be joined as their union easily:
The difference between two sets can be obtained easily:
Set elements can be removed easily:
Set equivalency is independent of order:
Sets may be of mixed type:
Set elements can be removed in multiple:
Set
s are Iterable
s that contain no duplicate elements.
Set
s are Iterable
s that contain no duplicate elements. The operations on sets are summarized in the following table for general sets and in the table after that for mutable sets. They fall into the following categories:
* **Tests** contains
, apply
, subsetOf
. The contains
method asks whether a set contains a given element. The apply
method for a set is the same as contains
, so set(elem)
is the same as set contains elem
. That means sets can also be used as test functions that return true for the elements they contain.
* **Additions** +
and ++
, which add one or more elements to a set, yielding a new set.
* **Removals** -
, --
, which remove one or more elements from a set, yielding a new set.
* **Set operations** for union, intersection, and set difference. Each of these operations exists in two forms: alphabetic and symbolic. The alphabetic versions are intersect
, union
, and diff
, whereas the symbolic versions are &
, |
, and &~
. In fact, the ++
that Set inherits from Traversable
can be seen as yet another alias of union
or |
, except that ++
takes a Traversable
argument whereas union
and |
take sets.
Sets can be created easily:
Attempted removal of nonexistent elements from a set is handled gracefully:
A set is either a subset of another set or it isn't:
Set elements can be removed with a tuple:
This method has been deprecated in favor of macro assertion and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
This method has been deprecated in favor of macro assertion and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
This method has been deprecated in favor of macro assumption and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
This method has been deprecated in favor of macro assumption and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
Please use 'an [Exception] should be thrownBy { ... }' syntax instead
This expect method has been deprecated. Please replace all invocations of expect with an identical invocation of assertResult instead.
This expect method has been deprecated. Please replace all invocations of expect with an identical invocation of assertResult instead.
This expectResult method has been deprecated. Please replace all invocations of expectResult with an identical invocation of assertResult instead.
This expectResult method has been deprecated. Please replace all invocations of expectResult with an identical invocation of assertResult instead.