Reputation: 979
What can be written to determine the version of Kotlin at runtime?
fun main(args : Array<String>) {
println("v" + System.getProperty("java.version"))
}
prints a version, but it is the Java JDK version. Using "kotlin.version" prints null. Can this be done at runtime?
If the general answer is no, is there a way to embed this information from the compile phase into a particular function or class?
Upvotes: 13
Views: 6299
Reputation: 4753
Use kotlin.KotlinVersion.CURRENT
:
fun main(args: Array<String>) {
println(KotlinVersion.CURRENT)
}
Try it out here by changing the version in the bottom-right corner of the page.
Upvotes: 27