
19 Feb
2024
19 Feb
'24
10:22 a.m.
On Sun, Feb 18, 2024 at 3:05 AM Information via ruby-talk < ruby-talk@ml.ruby-lang.org> wrote:
Hi p(1 and 2 or 3 and 4) 1. how many brackets do we need?
none if you know the order :)
2. in my opinion the result should be 2, not 4. What do you think?
1 and 2 or 3 and 4 => 4
evaluation left to right
1 && 2 || 3 && 4 => 2
evaluation 1st: 1 && 2 => 2 evaluation 2nd: 3 && 4 => 4 evaluation last: 2 || 4 => 2 "or" and "and" have same priority. "&&" precedes "||". check: https://docs.ruby-lang.org/en/master/syntax/precedence_rdoc.html kind regards --botp Andreas