Answer the question
In order to leave comments, you need to log in
Which design is correct?
There is a method that searches for a matching user, returns true if the user is found, false otherwise. Actually the question is what design is considered preferable? return selectedUser.Any() ? true : false;
or
if (!selectedUser.Any())
return true;
return false;
Answer the question
In order to leave comments, you need to log in
The second construction, IMHO, is readability hell, the indents correspond to the weather on Mars. In my opinion it is better to write like this:
if (!selectedUser.Any()){
return true;
}
else{
return false;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question