is there a way to get a java::class for nullable t...
# announcements
j
is there a way to get a java::class for nullable types for annotation checking?
k
In the first one, you're not actually getting the class of type
T
, you're getting the class of the value that currently happens to be stored in
value
.
And that concept doesn't make sense for the second one, what do you do when
value == null
?
Maybe what you actually want is a
Class<T>
constructor parameter? You can make it a bit nicer to call with a
reified
factory function.
d
::value.returnType
would be whatever type
value
is declared as in the source. In this case that would be
T
, with
returnType.jvmErasure
you can find the closest approximation that's known for
T
at runtime, in this case
Any::class
j
thanks