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
here your not creating a class. instead your just creating extension function and without class how can u get its package name. class "String" not belongs to "com.example" package
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.