NumericChar

The companion object for NumericChar that offers factory methods that produce NumericChars and maximum and minimum constant values for NumericChar.

Companion:
class
Source:
NumericChar.scala
class Object
trait Matchable
class Any

Value members

Concrete methods

def ensuringValid(value: Char): NumericChar

A factory/assertion method that produces a NumericChar given a valid Char value, or throws AssertionError, if given an invalid Char value.

A factory/assertion method that produces a NumericChar given a valid Char value, or throws AssertionError, if given an invalid Char value.

Note: you should use this method only when you are convinced that it will always succeed, i.e., never throw an exception. It is good practice to add a comment near the invocation of this method indicating ''why'' you think it will always succeed to document your reasoning. If you are not sure an ensuringValid call will always succeed, you should use one of the other factory or validation methods provided on this object instead: isValid, tryingValid, passOrElse, goodOrElse, or rightOrElse.

This method will inspect the passed Char value and if it is a numeric Char, it will return a NumericChar representing that value. Otherwise, the passed Char value is not numeric, so this method will throw AssertionError.

This factory method differs from the apply factory method in that apply is implemented via a macro that inspects Char literals at compile time, whereas this method inspects Char values at run time. It differs from a vanilla assert or ensuring call in that you get something you didn't already have if the assertion succeeds: a type that promises a Char is numeric.

Value parameters:
value

the Char to inspect, and if numeric, return wrapped in a NumericChar.

Returns:

the specified Char value wrapped in a NumericChar, if it is numeric, else throws AssertionError.

Throws:
AssertionError

if the passed value is not numeric

Source:
NumericChar.scala
def from(value: Char): Option[NumericChar]

A factory method that produces an Option[NumericChar] given a Char value.

A factory method that produces an Option[NumericChar] given a Char value.

This method will inspect the passed Char value and if it is a numeric Char, i.e., between '0' and '9', it will return a NumericChar representing that value, wrapped in a Some. Otherwise, the passed Char value is not a numeric character value, so this method will return None.

This factory method differs from the apply factory method in that apply is implemented via a macro that inspects Char literals at compile time, whereas from inspects Char values at run time.

Value parameters:
value

the Char to inspect, and if numeric, return wrapped in a Some[NumericChar].

Returns:

the specified Char value wrapped in a Some[NumericChar], if it is numeric, else None.

Source:
NumericChar.scala
def fromOrElse(value: Char, default: => NumericChar): NumericChar

A factory method that produces a NumericChar given a Char value and a default NumericChar.

A factory method that produces a NumericChar given a Char value and a default NumericChar.

This method will inspect the passed Char value and if it is a valid numeric Char (between '0' and '9'), it will return a NumericChar representing that value. Otherwise, the passed Char value is a non-digit character, so this method will return the passed default value.

This factory method differs from the apply factory method in that apply is implemented via a macro that inspects Char literals at compile time, whereas fromOrElse inspects Char values at run time.

Value parameters:
default

the NumericChar to return if the passed Char value is not numeric.

value

the Char to inspect, and if numeric, return.

Returns:

the specified Char value wrapped in a NumericChar, if it is numeric, else the default NumericChar value.

Source:
NumericChar.scala
def goodOrElse[B](value: Char)(f: Char => B): Or[NumericChar, B]

A factory/validation method that produces a NumericChar, wrapped in a Good, given a valid Char value, or if the given Char is invalid, an error value of type B produced by passing the given invalid Char value to the given function f, wrapped in a Bad.

A factory/validation method that produces a NumericChar, wrapped in a Good, given a valid Char value, or if the given Char is invalid, an error value of type B produced by passing the given invalid Char value to the given function f, wrapped in a Bad.

This method will inspect the passed Char value and if it is a numeric Char, it will return a NumericChar representing that value, wrapped in a Good. Otherwise, the passed Char value is NOT numeric, so this method will return a result of type B obtained by passing the invalid Char value to the given function f, wrapped in a Bad.

This factory method differs from the apply factory method in that apply is implemented via a macro that inspects Char literals at compile time, whereas this method inspects Char values at run time.

Value parameters:
value

the Char to inspect, and if numeric, return wrapped in a Good(NumericChar).

Returns:

the specified Char value wrapped in a Good(NumericChar), if it is numeric, else a Bad(f(value)).

Source:
NumericChar.scala
def isValid(value: Char): Boolean

A predicate method that returns true if a given Char value is between '0' and '9'.

A predicate method that returns true if a given Char value is between '0' and '9'.

Value parameters:
value

the Char to inspect, and if numeric, return true.

Returns:

true if the specified Char is numeric, else false.

Source:
NumericChar.scala
def passOrElse[E](value: Char)(f: Char => E): Validation[E]

A validation method that produces a Pass given a valid Char value, or an error value of type E produced by passing the given invalid Char value to the given function f, wrapped in a Fail.

A validation method that produces a Pass given a valid Char value, or an error value of type E produced by passing the given invalid Char value to the given function f, wrapped in a Fail.

This method will inspect the passed Char value and if it is a numeric Char (between '0' and '9'), it will return a Pass. Otherwise, the passed Char value is non-numeric, so this method will return a result of type E obtained by passing the invalid Char value to the given function f, wrapped in a Fail.

This factory method differs from the apply factory method in that apply is implemented via a macro that inspects Char literals at compile time, whereas this method inspects Char values at run time.

Value parameters:
value

the Char to validate that it is numeric.

Returns:

a Pass if the specified Char value is numeric, else a Fail containing an error value produced by passing the specified Char to the given function f.

Source:
NumericChar.scala
def rightOrElse[L](value: Char)(f: Char => L): Either[L, NumericChar]

A factory/validation method that produces a NumericChar, wrapped in a Right, given a valid Char value, or if the given Char is invalid, an error value of type L produced by passing the given invalid Char value to the given function f, wrapped in a Left.

A factory/validation method that produces a NumericChar, wrapped in a Right, given a valid Char value, or if the given Char is invalid, an error value of type L produced by passing the given invalid Char value to the given function f, wrapped in a Left.

This method will inspect the passed Char value and if it is a numeric Char (between '0' and '9'), it will return a NumericChar representing that value, wrapped in a Right. Otherwise, the passed Char value is NOT numeric, so this method will return a result of type L obtained by passing the invalid Char value to the given function f, wrapped in a Left.

This factory method differs from the apply factory method in that apply is implemented via a macro that inspects Char literals at compile time, whereas this method inspects Char values at run time.

Value parameters:
value

the Char to inspect, and if numeric, return wrapped in a Right(NumericChar).

Returns:

the specified Char value wrapped in a Right(NumericChar), if it is numeric, else a Left(f(value)).

Source:
NumericChar.scala
def tryingValid(value: Char): Try[NumericChar]

A factory/validation method that produces a NumericChar, wrapped in a Success, given a valid Char value, or if the given Char is invalid, an AssertionError, wrapped in a Failure.

A factory/validation method that produces a NumericChar, wrapped in a Success, given a valid Char value, or if the given Char is invalid, an AssertionError, wrapped in a Failure.

This method will inspect the passed Char value and if it represents a numeric value (between '0' and '9'), it will return a NumericChar representing that value, wrapped in a Success. Otherwise, the passed Char value is not numeric, so this method will return an AssertionError, wrapped in a Failure.

This factory method differs from the apply factory method in that apply is implemented via a macro that inspects Char literals at compile time, whereas this method inspects Char values at run time.

Value parameters:
value

the Char to inspect, and if numeric, return wrapped in a Success(NumericChar).

Returns:

the specified Char value wrapped in a Success(NumericChar), if it is numeric, else a Failure(AssertionError).

Source:
NumericChar.scala

Concrete fields

The largest value representable as a NumericChar.

The largest value representable as a NumericChar.

Source:
NumericChar.scala

The smallest value representable as a NumericChar.

The smallest value representable as a NumericChar.

Source:
NumericChar.scala

Implicits

Implicits

implicit inline def apply(value: => Char): NumericChar

A factory method, implemented via a macro, that produces a NumericChar if passed a valid Char literal, otherwise a compile time error.

A factory method, implemented via a macro, that produces a NumericChar if passed a valid Char literal, otherwise a compile time error.

The macro that implements this method will inspect the specified Char expression at compile time. If the expression is a numeric Char literal, i.e., a value between '0' and '9', it will return a NumericChar representing that value. Otherwise, the passed Char expression is either a literal that is not numeric, or is not a literal, so this method will give a compiler error.

This factory method differs from the from factory method in that this method is implemented via a macro that inspects Char literals at compile time, whereas from inspects Char values at run time.

Value parameters:
value

the Char literal expression to inspect at compile time, and if numeric, to return wrapped in a NumericChar at run time.

Returns:

the specified, valid Char literal value wrapped in a NumericChar. (If the specified expression is not a valid Char literal, the invocation of this method will not compile.)

Source:
NumericChar.scala
implicit def widenToDouble(value: NumericChar): Double

Implicit widening conversion from NumericChar to Double.

Implicit widening conversion from NumericChar to Double.

Value parameters:
value

the NumericChar to widen

Returns:

the Double widen from the specified NumericChar.

Source:
NumericChar.scala

Implicit widening conversion from NumericChar to FiniteDouble.

Implicit widening conversion from NumericChar to FiniteDouble.

Value parameters:
pos

the NumericChar to widen

Returns:

the Int value underlying the specified NumericChar, widened to Double and wrapped in a FiniteDouble.

Source:
NumericChar.scala

Implicit widening conversion from NumericChar to FiniteFloat.

Implicit widening conversion from NumericChar to FiniteFloat.

Value parameters:
pos

the NumericChar to widen

Returns:

the Int value underlying the specified NumericChar, widened to Float and wrapped in a FiniteFloat.

Source:
NumericChar.scala
implicit def widenToFloat(value: NumericChar): Float

Implicit widening conversion from NumericChar to Float.

Implicit widening conversion from NumericChar to Float.

Value parameters:
value

the NumericChar to widen

Returns:

the Float widen from the specified NumericChar.

Source:
NumericChar.scala
implicit def widenToInt(value: NumericChar): Int

Implicit widening conversion from NumericChar to Int.

Implicit widening conversion from NumericChar to Int.

Value parameters:
value

the NumericChar to widen

Returns:

the Int widen from the specified NumericChar.

Source:
NumericChar.scala
implicit def widenToLong(value: NumericChar): Long

Implicit widening conversion from NumericChar to Long.

Implicit widening conversion from NumericChar to Long.

Value parameters:
value

the NumericChar to widen

Returns:

the Long widen from the specified NumericChar.

Source:
NumericChar.scala

Implicit widening conversion from NumericChar to PosDouble.

Implicit widening conversion from NumericChar to PosDouble.

Value parameters:
pos

the NumericChar to widen

Returns:

the Int value underlying the specified NumericChar, widened to Double and wrapped in a PosDouble.

Source:
NumericChar.scala

Implicit widening conversion from NumericChar to PosFiniteDouble.

Implicit widening conversion from NumericChar to PosFiniteDouble.

Value parameters:
pos

the NumericChar to widen

Returns:

the Int value underlying the specified NumericChar, widened to Double and wrapped in a PosFiniteDouble.

Source:
NumericChar.scala

Implicit widening conversion from NumericChar to PosFiniteFloat.

Implicit widening conversion from NumericChar to PosFiniteFloat.

Value parameters:
pos

the NumericChar to widen

Returns:

the Int value underlying the specified NumericChar, widened to Float and wrapped in a PosFiniteFloat.

Source:
NumericChar.scala

Implicit widening conversion from NumericChar to PosFloat.

Implicit widening conversion from NumericChar to PosFloat.

Value parameters:
pos

the NumericChar to widen

Returns:

the Int value underlying the specified NumericChar, widened to Float and wrapped in a PosFloat.

Source:
NumericChar.scala
implicit def widenToPosInt(pos: NumericChar): PosInt

Implicit widening conversion from NumericChar to PosInt.

Implicit widening conversion from NumericChar to PosInt.

Value parameters:
pos

the NumericChar to widen

Returns:

the Int value underlying the specified NumericChar, widened to Int and wrapped in a PosInt.

Source:
NumericChar.scala
implicit def widenToPosLong(pos: NumericChar): PosLong

Implicit widening conversion from NumericChar to PosLong.

Implicit widening conversion from NumericChar to PosLong.

Value parameters:
pos

the NumericChar to widen

Returns:

the Int value underlying the specified NumericChar, widened to Long and wrapped in a PosLong.

Source:
NumericChar.scala

Implicit widening conversion from NumericChar to PosZDouble.

Implicit widening conversion from NumericChar to PosZDouble.

Value parameters:
pos

the NumericChar to widen

Returns:

the Int value underlying the specified NumericChar, widened to Double and wrapped in a PosZDouble.

Source:
NumericChar.scala

Implicit widening conversion from NumericChar to PosZFiniteDouble.

Implicit widening conversion from NumericChar to PosZFiniteDouble.

Value parameters:
pos

the NumericChar to widen

Returns:

the Int value underlying the specified NumericChar, widened to Double and wrapped in a PosZFiniteDouble.

Source:
NumericChar.scala

Implicit widening conversion from NumericChar to PosZFiniteFloat.

Implicit widening conversion from NumericChar to PosZFiniteFloat.

Value parameters:
pos

the NumericChar to widen

Returns:

the Int value underlying the specified NumericChar, widened to Float and wrapped in a PosZFiniteFloat.

Source:
NumericChar.scala

Implicit widening conversion from NumericChar to PosZFloat.

Implicit widening conversion from NumericChar to PosZFloat.

Value parameters:
pos

the NumericChar to widen

Returns:

the Int value underlying the specified NumericChar, widened to Float and wrapped in a PosZFloat.

Source:
NumericChar.scala
implicit def widenToPosZInt(pos: NumericChar): PosZInt

Implicit widening conversion from NumericChar to PosZInt.

Implicit widening conversion from NumericChar to PosZInt.

Value parameters:
pos

the NumericChar to widen

Returns:

the Int value underlying the specified NumericChar, widened to Int and wrapped in a PosZInt.

Source:
NumericChar.scala

Implicit widening conversion from NumericChar to PosZLong.

Implicit widening conversion from NumericChar to PosZLong.

Value parameters:
pos

the NumericChar to widen

Returns:

the Int value underlying the specified NumericChar, widened to Long and wrapped in a PosZLong.

Source:
NumericChar.scala