vendredi 29 octobre 2021

Coding convention for If statement and returning

I'm not sure if I'm overthinking this but should I do this

if (!searchList.isEmpty()) {
    String search = searchList.get(0).getText();
    return List.of(search.split("\n"));
} else {
    return null;
}

or should I do this

if (!searchList.isEmpty()) {
    String search = searchList.get(0).getText();
    return List.of(search.split("\n"));
}
return null;
        

Aucun commentaire:

Enregistrer un commentaire