In Kotlin (Android project), which is preferable to use ?
isNullOrEmpty
or TextUtils.isEmpty
and why
I believe they do the exact thing and are "null" safe, right ?
Based off of my question here
If your project will be ported to other frameworks, making use of isNullOrEmpty
will probably result in a safer experience, because it's based on Kotlin (specifically package kotlin.text
) and not on package android.text;
Why is this safer ?
Well, the implementation of isNullOrEmpty
might change depending on the platform but it will be available to use and is part of Kotlin, compared to TextUtils.isEmpty
being only for android.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With