unaryMinus

operator fun unaryMinus(): Integer

Returns the negative of this integer.


Calling from Kotlin

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

// Given
val x: Integer = Integer.from(9223372036854775807)
// When
val result: Integer = -x
// Then
val expected: Integer = Integer.from(-9223372036854775807)
check(result == expected)

Calling from Java

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

// Given
final Integer x = Integer.from(9223372036854775807L);
// When
final Integer result = x.unaryMinus();
// Then
final Integer expected = Integer.from(-9223372036854775807L);
final boolean check = result.equals(expected);
if (!check) throw new IllegalStateException("Check failed.");