6 ms·
`and`, `or`, `not` have much lower precedence than `&&`, `||` and `!` . I would just avoid `and` and `or` in general. For some more explanation see https://gra
by sinkwool 3y ago
`and`, `or`, `not` have much lower precedence than `&&`, `||` and `!` . I would just avoid `and` and `or` in general.
For some more explanation see https://graceful.dev/courses/the-freebies/modules/ruby-language/topic/episode-125-and-or/ https://graceful.dev/courses/the-freebies/modules/ruby-langu...
- djur 3y agoRubocop forbids the use of `and` and `or` in a value expression for this reason, and I believe several style guides used with Rubocop ban them entirely. I like them but have come to accept that they're more trouble than they're worth (in a shared codebase with lots of contributors, at least).