vendredi 11 janvier 2019

Redundant 'if' statement less

My code is as below

 private fun validateInput(): Boolean {
     if (etReportRow1.text.toString() == "" 
         || etReportRow2.text.toString() == "" 
         || etReportRow3.text.toString() == "")
         return false
     else
         return true
 }

The compiler tell me

Redundant 'if' statement less... (Ctrl+F1) This inspection reports if statements which can be simplified to single statements. For example: if (foo()) { return true } else { return false } can be simplified to return foo().

Won't the suggested code go into loop?

Aucun commentaire:

Enregistrer un commentaire