final class LoneElementCollectionWrapper[E, CTC[_]] extends AnyRef
Wrapper class that adds a loneElement
method to any collection type C
for which
an implicit Collecting[C]
is available.
Through the implicit conversion provided by trait LoneElement
, this class allows you to make statements like:
trav.loneElement should be > 9
- E
the element type of the collection on which to add the
loneElement
method- CTC
the "collection type constructor" for the collection on which to add the
loneElement
method
- Source
- LoneElement.scala
- Alphabetic
- By Inheritance
- LoneElementCollectionWrapper
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
LoneElementCollectionWrapper(collection: CTC[E], collecting: Collecting[E, CTC[E]], prettifier: Prettifier, pos: Position)
- collection
a collection to wrap in a
LoneElementCollectionWrapper
, which provides theloneElement
method.- collecting
a typeclass that enables the
loneElement
syntax
Value Members
-
def
loneElement: E
Returns the value contained in the wrapped collection, if it contains one and only one element, else throws
TestFailedException
with a detail message describing the problem.Returns the value contained in the wrapped collection, if it contains one and only one element, else throws
TestFailedException
with a detail message describing the problem.This method enables syntax such as the following:
trav.loneElement should be > 9 ^