Const val in both code and annotations

Can I write something like this?

 const val path = "some/path"
 @SomeAnnotation(path = path)
 class Foobar
1 Like

Apparently, you can.

I just tried this and it compiled OK:

const val PATH = "somePath"

annotation class SomeAnnotation(val path: String)

@SomeAnnotation(path = PATH)
class Foobar

Have you had a case where it didn’t work?

1 Like

Thanks, @alanfo
I had troubles adding kapt to my project, now I did it, and it turned out this works