fromByte

fun fromByte(number: Byte): Zero

Creates an instance of Zero from the specified number, or throws an IllegalArgumentException if the number is other than zero.


Calling from Kotlin

Here's an example of calling this function from Kotlin code:

val number: Byte = 0
val isSuccess: Boolean = try {
Zero.fromByte(number)
true
} catch (exception: IllegalArgumentException) {
false
}
assertTrue(isSuccess)

Calling from Java

Here's an example of calling this function from Java code:

final byte number = 0;
boolean isSuccess;
try {
Zero.fromByte(number);
isSuccess = true;
} catch (final IllegalArgumentException exception) {
isSuccess = false;
}
Assertions.assertTrue(isSuccess);

See the fromByteOrNull function for returning null instead of throwing an exception in case of invalid number.