jeudi 28 septembre 2017

if-else, ternary operator readability

I've been discussing with my colleges and I want your opinion , which option is better in terms of readability?

private boolean isGreatherThan(int a, int b){

    return a>b ? true : false;
}

private boolean isGreatherThan(int a, int b){

    if(a>b){

        return true;
    }   

    return false;
} 


 private boolean isGreatherThan(int a, int b){

    if(a>b){   

            return true;

        }else{  

            return false;
        }
    }

Aucun commentaire:

Enregistrer un commentaire