+ 4
Like this?
object E {
const val v = 2
}
class T() {
companion object {
const val d = 5
const val n = E.v
}
}
+ 3
Constants must be known at compile time and can not be instance based.
+ 3
You can even do math, as long as it can be calculated by the compiler, like:
class N() {
companion object {
const val t = T.d+T.n
}
}
+ 2
If the constant object or its properties have the correct data type for the assignment, they can be used. That is a read only operation so is perfectly fine usage of any constant.
Do you have an explict example you are asking about?