I want to branch on "negative, zero, one, or other...
# getting-started
b
I want to branch on "negative, zero, one, or other". Is this the best way?
Copy code
fun Integer.toThePowerOf(exponent: Integer): Integer =
        when (exponent) {
            in (Integer.min..0) -> 0
            1L -> this
            else -> Math.pow(this.toDouble(), exponent.toDouble()).toLong()
        }