When I try put the const val like this:
const val DRAWABLE_RIGHT : Int = 2
inside a method, I get the error:
Modifier 'const' is not applicable to 'local variable'
And when I move this const val to the top of class like this:
class MyClass @JvmOverloads constructor(context: Context) : ConstraintLayout(context) {
const val DRAWABLE_RIGHT : Int = 2
...
}
the compiler say that it's still incorrect:
Const 'val' are only allowed on top level or in objects
What does it mean top level?