i can't be the only one that thinks the constant c...
# getting-started
h
i can't be the only one that thinks the constant casting between ints, doubles, etc in arithmetic kinda ruins the beautiful readability of kotlin
h
Have an example of when it's ugly in arithmetic?
h
how about a^2 + b^2 = c^2:
fun Pair<Int,Int>.distanceTo(to: Pair<Int,Int>): Float = sqrt((this.first - to.first).toDouble().pow(2.0) + (this.second - to.second).toDouble().pow(2.0)).toFloat()
the important things to consider in arithmetic are the mathematical operators, but the casting dominates the lines
especially when working with java classes that have the autocasting, so set field types to whatever number type, then in kotlin you have to constantly cast to it
h
So in that example, you could add a
pow
extension function to
Int
right and avoid all the conversion calls? Or are ya looking for a lib that has already defined many extensions like that on numeric types?