# codereview

Alex Woods

02/10/2020, 6:14 PM
Hey guys, got 2 questions about default values and annotations. 1. Is there a way to get the default value of a parameter using reflection?
Copy code
data class Foo(val a: String = "hello")

// can I access "hello" somehow, like { it.defaultValue }
2. What’s the maximum supertype I can use on an annotation? I know annotations can only take certain values (primitives in Java, classes, etc.).
Copy code
annotation class Bar<T>(val value: T)   // nope!

annotation class Bar(val value: Any)   // nope!
Is there some supertype for anything that is valid in an annotation?
I suspect the answer to 1 is “no, it’s not possible”. 2 I think there is some good pattern to use


02/10/2020, 7:30 PM
In 1 you can create an instance of this data class with default values (but it's a bit tricky) and then iterate over it's properies