implicit final class Requiring[A] extends AnyVal
Ordering
- Alphabetic
- By Inheritance
Inherited
- Requiring
- AnyVal
- Any
Implicitly
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
Visibility
- Public
- Protected
Instance Constructors
- new Requiring(value: A)
- value
The value to check.
Value Members
- def getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
- def requiring(cond: (A) => Boolean, msg: => Any): A
Check that a condition is true for the
value
.Check that a condition is true for the
value
. If true, returnvalue
, otherwise throw anIllegalArgumentException
with the given message.- cond
The function used to check the
value
.- msg
The message to report if the condition isn't met.
- Annotations
- @inline()
- def requiring(cond: Boolean, msg: => Any): A
Check that a condition is true.
Check that a condition is true. If true, return
value
, otherwise throw anIllegalArgumentException
with the given message.- cond
The condition to check.
- msg
The message to report if the condition isn't met.
- Annotations
- @inline()
- val value: A
Implicit class providing
requiring
methods. This class is based onPredef.ensuring
in the Scala standard library. The difference is that this class's methods throwIllegalArgumentException
s rather thanAssertionError
s.An example adapted from
Predef
's documentation: