```object Extensions{ fun TextUtils.check...
# android
s
Copy code
object Extensions{
    
    fun TextUtils.checkEmpty(str: String?): String? {
        if (!TextUtils.isEmpty(str)) {
            return str
        } else {
            return null
        }
    }
    
}
I have written this but not able to access this method. What is getting wrong here ??
m
You declared an extension function on
TextUtils
, therefore you need to call it on an instance of
TextUtils
, which cannot be instantiated, because it has private constructor.
e
note, there is no need for `TextUtils`as Kotlin already gives you
Copy code
str?.ifEmpty { null }
☝️ 1