Operator Precedence Conundrum

I don’t get this:

2.4.0 :001 > (false && false ? false : true)
=> true

Interestingly:

2.4.0 :002 > (false and false ? false : true)
=> false

Parentheses can be used to produce the intended result:

2.4.0 :003 > (false && (false ? false : true))
=> false

But still the first case makes no sense to me. Short circuit evaluation
would seem to dictate that the first instance should return false.

Thanks in advance for any enlightenment.

The && operator has higher precedense than ?:

The and operator has lower precedence than ?:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs