kotlin - Why can't I get the class of a generic parameter? -


i have function takes 1 argument of generic type , want access class of it:

fun <t> test(t: t) {     t::class } 

this fails "expression in class literal has nullable type". that's ok, understand (i use any? t , null value).
if change guaranty t not-null still fails same error message:

fun <t> test(t: t) {     t!!::class } 

in case can t!!::class still cause trouble?
there way class without using (or casting any)?

change type indicate not-nullable , should work. can indicating t needs extend any (rather any?).

fun <t : any> test(t: t) {     t::class } 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -