Just like in maths : Order of Operations - BODMAS or
In general programming languages, && has higher precedence than || operator.
But in Ruby it is not like that as and or have same order of precedence.
Lets see one example :
"a" || "b" && "c" will be assumed as => "a" || ("b" && "c")
output: "a" ("b", "c" are never called) why as "a" is always true.
here && has higher precedence than ||
Lets see with and or operations
"a" or "b" and "c" will be assumed as => ("a" or "b") and "c"
output: "c"
In general programming languages, && has higher precedence than || operator.
But in Ruby it is not like that as and or have same order of precedence.
Lets see one example :
"a" || "b" && "c" will be assumed as => "a" || ("b" && "c")
output: "a" ("b", "c" are never called) why as "a" is always true.
here && has higher precedence than ||
Lets see with and or operations
"a" or "b" and "c" will be assumed as => ("a" or "b") and "c"
output: "c"