We would like to introduce an experimentalStrictlyNegativeInt.Companion.create function for accepting a customized exception message.
fun StrictlyNegativeInt.Companion.create(
number: Number,
message: (Number) -> Any
): StrictlyNegativeInt
This function throws an IllegalArgumentException with the specified message if the specified number is greater than or equals zero. If the message has a blank string representation, it throws the exception with a generic message instead.
Here are some examples of calling this function from Kotlin code:
println(StrictlyNegativeInt.create(-1) { "$it should be less than zero." }) // -1
StrictlyNegativeInt.create(0) { "$it should be less than zero." } // throws an exception with the specified message
StrictlyNegativeInt.create(-1) { " " } // throws an exception with a generic message
The StrictlyNegativeInt type being an inline value class, this function shouldn't be available yet for Java users.
π Description
We would like to introduce an experimental
StrictlyNegativeInt.Companion.create
function for accepting a customized exception message.This function throws an
IllegalArgumentException
with the specifiedmessage
if the specifiednumber
is greater than or equals zero. If themessage
has a blank string representation, it throws the exception with a generic message instead.Here are some examples of calling this function from Kotlin code:
The
StrictlyNegativeInt
type being an inline value class, this function shouldn't be available yet for Java users.β Checklist