What's preferred in Kotlin - casting or reified Ge...
# announcements
v
What's preferred in Kotlin - casting or reified Generics? I'm using reflection to build arbitrary objects given some values in a
request
(from Spark-Kotlin). It started with
val person = Form(request,Person::class).get() as Person
. Then i created an extension function
val person = request.bind(Person::class) as Person
. Latest version uses reified generics
val person = request.bind<Person>()
. Are there any clear problems using the reified generic extension function approach?
g
considering std functions like
enumValues<Foo>()
reified approach is pretty common
😀 1
c
+1 for reified, it's cleaner, nicer and it was created exactly for this reason 🙂