https://kotlinlang.org logo
n

natpryce

11/24/2017, 3:10 PM
Hi. If I have a KClass<T>, how do I safely cast a value of type Any to a value of type T? I’m looking for a dynamic equivalent to the
as?
operator.
u

udalov

11/30/2017, 4:11 PM
n

natpryce

11/30/2017, 8:48 PM
Yes, I should say… this is a multiplatform project.
For some reason, KClass.cast is not available in JavaScript, although using a reified type parameter with
as?
works.
3 Views