Shawn
07/03/2018, 5:48 AMbuttonRegister.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 usePavlo Liapota
07/03/2018, 7:01 AMbuttonRegister.isEnabled = if (TextUtils.isEmpty(email) && TextUtils.isEmpty(password) && TextUtils.isEmpty(confirmPassword)) false else true
😛
But I would prefer
val emptyFields = TextUtils.isEmpty(email) && TextUtils.isEmpty(password) && TextUtils.isEmpty(confirmPassword)
buttonRegister.isEnabled = !emptyFields
But as was suggested using isNotEmpty()
would be best.||
instead of &&
, i.e. button should be disabled if any field is empty?Ayden
07/03/2018, 7:03 AM