We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I see a complex a conditional logic in https://github.com/codereading/rack/blob/rack-1.4/lib/rack/showexceptions.rb#L46
def prefers_plain_text?(env) env["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest" && (!env["HTTP_ACCEPT"] || !env["HTTP_ACCEPT"].include?("text/html")) end
If I have a long conditional logic like this, I would break each part to make it easy to read:
def prefers_plain_text?(env) env["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest" && !(env["HTTP_ACCEPT"] and env["HTTP_ACCEPT"].include?("text/html")) end
The text was updated successfully, but these errors were encountered:
@samnang I agree that splitting the line makes it easier to read, however I think the original version of the 2nd conditinal logic reads more cleanly.
I.e.
(!env["HTTP_ACCEPT"] || !env["HTTP_ACCEPT"].include?("text/html"))
vs
!(env["HTTP_ACCEPT"] and env["HTTP_ACCEPT"].include?("text/html"))
&&
and
Sorry, something went wrong.
Hi @jhuckabee
Keeping the NOT operator with each condition makes it flow easier when you read it.
Sometimes it does that way, but this code it doesn't help because our brain will interpret more ! and ||, that's make it more complex.
!
||
I find the use of && and and together inconsistent and distracting. Was that done on purpose?
I don't know most of the time I usually use and and or, but I use && and || whenever I think about operator precedence. So what do you think?
or
No branches or pull requests
I see a complex a conditional logic in https://github.com/codereading/rack/blob/rack-1.4/lib/rack/showexceptions.rb#L46
If I have a long conditional logic like this, I would break each part to make it easy to read:
The text was updated successfully, but these errors were encountered: