Hi all, may be a pretty basic question, but I've j...
# getting-started
t
Hi all, may be a pretty basic question, but I've just hit a problem where using a constant defined in an object for a
@Supress
doesn't work - so
Copy code
object SupressionNames {
    const val MAGIC_NUMBER = "MAGIC_NUMBER"
}

// Another file somewhere
@Supress(SupressionNames.MAGIC_NUMBER)
fun foo(...) { ... }
If I define the constant without the object, then it works just fine. But I'm just curious - why doesn't it work when using an object? And is it good practice to do this in the first place? (Would love to see some reading material if anyone knows any!). Cheers!
h
With object I expect it to work, but for such type of constant declaring them as top level properties is considered best practice.