Open samnang opened 12 years ago
@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 and
together inconsistent and distracting. Was that done on purpose?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?
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: