Created
March 11, 2018 13:48
-
-
Save ruwanka/caa3c11148fae026ee4638e7b7c9da14 to your computer and use it in GitHub Desktop.
kotlin infix functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
println(2 powerTo 4) | |
} | |
infix fun Int.powerTo(to: Int): Double { | |
return Math.pow(this.toDouble(), to.toDouble()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment