maybe I’m missing some context but it seems like y...
# codereview
s
maybe I’m missing some context but it seems like you could at least simplify it to
buttonRegister.isEnabled = ! (isEmpty(email) && isEmpty(password) && isEmpty(confirmPassword))
but
!
is a source of contention among a lot of developers since it’s easy to miss or forget to use
p
At least you can write
Copy code
buttonRegister.isEnabled = if (TextUtils.isEmpty(email) && TextUtils.isEmpty(password) && TextUtils.isEmpty(confirmPassword)) false else true
😛 But I would prefer
Copy code
val emptyFields = TextUtils.isEmpty(email) && TextUtils.isEmpty(password) && TextUtils.isEmpty(confirmPassword)
buttonRegister.isEnabled = !emptyFields
But as was suggested using
isNotEmpty()
would be best.
BTW, @Ayden, shouldn’t you use
||
instead of
&&
, i.e. button should be disabled if any field is empty?
a
@Pavlo Liapota you are right. The button will be disabled when one of the field is blank.