puts "true" if []
An empty array is still an object, so tests to true. Similarly 0, etc.
The only false values are 'false', of course, and 'nil', the lack of anything.
An empty array is still an object, so tests to true. Similarly 0, etc.
The only false values are 'false', of course, and 'nil', the lack of anything.
As of Ruby 1.9, multiple assignment in a conditional now returns whatever the right-hand side of the assignment operator evaluates to. So, it makes sense to re-allow multiple assignment inside conditionals and remove the parse error.
Here are some examples illustrating the return value of multiple assignment. The first two are truthy while the third is falsey:
- The above based on user 'bug hit' who attributes Yusuke Endoh, from https://bugs.ruby-lang.org/issues/10617