3 ms·
Rubies magic evaporated when I realized that its logic is unintuitive / broken: ``` puts true and not true >>> true x = true and false >>> true if 0; p
by singularity2001 8y ago
Rubies magic evaporated when I realized that its logic is unintuitive / broken:
```
puts true and not true
>>> true
x = true and false
>>> true
if 0; puts 'true';end
```
breaking backwards compatibility with every rails upgrade didn't help.
Similar bad behaviour in kotlin
- abhorrence 8y agoand/or/not have different precedence than &&/||/!. The symbol versions of each of those would behave as you would expect. However, I can’t say much in favor of the existence of the word forms.
- deleted 8y ago[deleted]
- dragonwriter 8y agoSo, your first two complaints are you not understanding Ruby operator precedence, not Ruby logic being broken, and the other is you not understanding Ruby truthiness (null and false are not truthy, all other builtin/stdlib values [and conventionally all other values] are falsely.)
- heartbreak 8y agoAnd the final complaint was about Rails, not Ruby.
- bdcravens 8y agoHasn't the use of "and" been considered a bad practice for years?
- weaksauce 8y agofor boolean operations yes... for control flow it's debatable.