The following looks like dirty code, but I can't think of how to make it more neat. Any ideas? I want to call doSearch for values 10, 20, and 30. If the results are not returned for the value, I want to try the following value. Otherwise, just exit. I know this will work, but is this the most readable way?
SearchResult result = doSearch("10");
if (result.getResults() == null) {
result = doSearch("20");
if (result.getResults() == null) {
result = doSearch("30");
if (result.getResults() == null) {
// put code to deal with lack of results here
}
}
}
source
share