I'd like to be able to overload the `caret`. Is th...
# language-proposals
g
I'd like to be able to overload the
caret
. Is there anything against this? (e.g.
operator Int.caret(x: Int): Int = Math.....
)
e
What precedence it should have? Like a bit-wise xor or like a power? That is a very tricky question.
g
The reason I suggested this in the first place is, that we had a few mathematical formulars to write, and we quickly saw that a e.g.
2^3
is much nicer to read than
Math.pow(2, 3)
So the answer in this case would be
power
Hm, but precedence is a good point which must be considered...
e
Or maybe
2 ** 3
?
Btw. you can do
2.0.pow(3)
in Kotlin 1.2
g
Hm,
**
isn't too bad. Is this already possible?
e
No. But
x.pow(y)
is already there and it is not much worse. Try it.
g
Thx. I will. I guess it will do it.