mercredi 4 novembre 2020

get name of file in android kotlin

I have an Extention function in file with the name StringEx.kt.

StringEx.kt

package com.example
        
fun String.addUnderline(): String {
    return "_" + this + "_"
}

how can get the name and package of the file("StringEx.kt") in other class?

for example:

println(StringEx:class.name)
// print com.example.StringEx




Aucun commentaire:

Enregistrer un commentaire