How is it recommended to create constants in Kotlin? And what's the naming convention? I've not found that in the documentation.
companion object {
//1
val MY_CONST = "something"
//2
const val MY_CONST = "something"
//3
val myConst = "something"
}
Or ...?
In Kotlin, if you want to create the local constants which are supposed to be used with in the class then you can create it like below
val MY_CONSTANT = "Constants"
And if you want to create a public constant in kotlin like public static final in java, you can create it as follow.
companion object{
const val MY_CONSTANT = "Constants"
}