irb(main):028:0> value = false or true
=> true
irb(main):029:0> value
=> false
That really makes me want to write it off entirely. It’s hard to think of a situation where this is the right behavior. irb(main):028:0> value = false or true
=> true
irb(main):029:0> value
=> false
That really makes me want to write it off entirely. It’s hard to think of a situation where this is the right behavior.I’m not saying that it isnt valid to criticize these things: first time use of a language matters, people work in multiple languages, it is good to be intuitive.
But in practice, these things aren’t problems for people who work regularly in these languages, so I personally find them to be quite low salience.
I recognize that this is sort of similar to the claims the hypothetical user of php makes in “php is a fractal of bad design”, but personally I find think the issues are of a different nature.
But then is being surprised by `["0","1","10"].map(parseInt) // => [0, NaN, 2]` in JavaScript a sign of bad language design or does it just mean that you don't have enough experience with the language yet?
For some more explanation see https://graceful.dev/courses/the-freebies/modules/ruby-langu...
however,
irb(main):001:0> value = false or true
=> true
irb(main):002:0> value
=> false
irb(main):003:0> value = false || true
=> true
irb(main):004:0> value
=> true
irb(main):005:0>
I believe if you use the `||` operator instead of `or`, then things just work out fine. I agree it is really annoying. But I am pretty sure if you use a tool like RuboCop https://github.com/rubocop/rubocop (a static code analysis tool) then it will catch bugs like this. Note that I am not recommending Ruby. But in my experience if I want to work with a language and it has a community style guide and a linter that enforces it, it will save me some heartache.Just editing to add this reference: https://rubystyle.guide/#and-or-flow