samedi 3 juillet 2021

Can you explain this::javaClass in kotlin?

sealed class Genre{
sealed class Fiction : Genre(){
    object Classics: Fiction()
    object Fantasy: Fiction()
    object ScienceFiction: Fiction()
}
sealed class NonFiction: Genre(){
    object Biography: NonFiction()
    object Business: NonFiction()
    object Feminism: NonFiction()
    object Politics: NonFiction()
    object SelfHelp: NonFiction()
}

override fun toString(): String {
    return this::javaClass.get().simpleName
}

I do not understand this context return this::javaClass...

When I press ctrl and hover over "this" it points to Genre class, This is confusing me.





Aucun commentaire:

Enregistrer un commentaire