https://kotlinlang.org logo
Title
a

Ayden

07/03/2018, 7:04 AM
@Shawn may I know what is the correct or best way of doing it?
p

Pavlo Liapota

07/03/2018, 7:12 AM
What does
TextUtils.isEmpty(email)
do? Is it the same as
string.isEmpty()
? If yes, then you can write
buttonRegister.isEnabled = email.isNotEmpty() && password.isNotEmpty() && confirmPassword.isNotEmpty()
g

gildor

07/03/2018, 7:23 AM
I suppose
TextUtils.isEmpty
is from Android
android.text.TextUtils
, so it’s like isNullOrEmpty(), but for non-null variables in Kotlin it can be replaced with isNotEmpty()
a

Ayden

07/03/2018, 9:56 AM
@Pavlo Liapota
TextUtils
is a package in Android.
g

gildor

07/03/2018, 10:24 AM
so instead you can use isEmpty(), isNotEmpty() or isNullOrEmpty(), depending on your use case and types
d

digitalsanctum

07/03/2018, 11:02 PM
how about:
buttonRegister.isEnabled = listOf(email, password, confirmPassword).none { it.isNullOrEmpty() }
?
1
r

rook

07/06/2018, 5:44 PM
@digitalsanctum that’s real fancy. I like that.
👍 1