Of course
a) Destructuring multiple function return
An old post of mine
b)
In my code, I’ve used my own " v" power operator. In this case, I need to use a letter. I cannot use the more intuitve ^, unless I used quotation marks
inline infix fun Double.v(exponent: Int): Double = this.pow(exponent)
inline infix fun Double.v(exponent: Long): Double = this.pow(exponent.toDouble())
inline infix fun Double.v(exponent: Double): Double = this.pow(exponent)
inline infix fun Int.v(exponent: Int): Double = this.toDouble().pow(exponent)
inline infix fun Int.v(exponent: Long): Double = this.toDouble().pow(exponent.toDouble())
inline infix fun Int.v(exponent: Double): Double = this.toDouble().pow(exponent)
inline infix fun Long.v(exponent: Int): Double = this.toDouble().pow(exponent)
inline infix fun Long.v(exponent: Long): Double = this.toDouble().pow(exponent.toDouble())
inline infix fun Long.v(exponent: Double): Double = this.toDouble().pow(exponent)
I’ve accepted to use v
, but I have some problems:
Unfortunately the v
priority is lower than +
println(2 v 5) // 32 (ok)
println(2+3 v 3) // 125 (29 expected)
println(3 v 2 + 1) // 27 (10 expected)
println(2 + 3 v 2 + 1) // 125 (12 expected)
So I need always to use parenthesis. it’s not intuitive, but it works well