Challenge 2: A Custom Annotation with a Reader — Solution import kotlin.reflect.KClass @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.RUNTIME) annotation class Author(val name: String) @Author("Philip Osztromok") class Report class UnattributedNotes fun printAuthor(kClass: KClass<*>) { val author = kClass.annotations.filterIsInstance().firstOrNull() if (author != null) { println("${kClass.simpleName} written by ${author.name}") } else { println("${kClass.simpleName}: No author") } } fun main() { printAuthor(Report::class) printAuthor(UnattributedNotes::class) } /* Output: Report written by Philip Osztromok UnattributedNotes: No author Notes: - @Retention(AnnotationRetention.RUNTIME) is required — without it, the annotation would compile fine but be invisible to reflection at runtime, and kClass.annotations would never find it. - kClass.annotations returns every annotation actually present on the class; filterIsInstance() narrows that list down to just Author annotations (there could in principle be others), and firstOrNull() safely handles the case where none is present. - Report has @Author applied, so its name comes back; UnattributedNotes has no such annotation, so the function falls through to the "No author" branch. */