mercredi 31 janvier 2018

How to get class of Any? variable in Kotlin?

I want my equals to compare class too and I wrote

    override fun equals(other: Any?): Boolean {
        return this::class == other::class && ...

    }

unfortunately it swears

Expression in a class literal has a nullable type 'Any?', use !! to make the type non-nullable

But I want to compare with nulls too. What about glorious "null safety"? They forgot it for reflection? I didn't find ?:: operator or something.





Aucun commentaire:

Enregistrer un commentaire