remOrNull

fun remOrNull(other: Integer): Integer?

Returns the remainder of dividing this integer by the other one, or returns null if the other integer is zero.


Calling from Kotlin

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

// Given
val x: Integer = Integer.from(42)
val y: Integer = Integer.from(5)
// When
val result: Integer? = x.remOrNull(y)
// Then
val expected: Integer = Integer.from(2)
check(result == expected)

This function is not available from Java code, due to its non-explicit support for nullable types.

See the rem function for throwing an exception instead of returning null in case of invalid other integer.