3 ms·
OK, newline is not equivalent to semicolon but I could be forgiven for inferring that from the documentation. e.g. "an expression is terminated with a newline
by emmelaich 8y ago
OK, newline is not equivalent to semicolon but I could be forgiven for inferring that from the documentation.
e.g. "an expression is terminated with a newline or semicolon"
(https://www.cs.auckland.ac.nz/references/ruby/doc_bundle/Manual/man-1.4/syntax.html#program https://www.cs.auckland.ac.nz/references/ruby/doc_bundle/Man...)
Re "void" I'm referring to rubocop warnings like "Operator + used in void context."
Here's another oddity; irb behaves differently for some expressions.
not_defined = "#{not_defined}"
=> ""
:-/
Anyway, the parens things bothers me the most. In most (all?) other languages, putting parens around a multiline expression would make it one atomic expression.
- vidarh 8y agoYeah, I understands it's confusing. The Ruby grammar does have some dark corners like that where the side effect of trying to make it possible to make things as free of punctuation as possible causes weirdness elsewhere. Putting parens around it does make it one atomic expression though, it's just that in effect the "operators" are ;/lf, and these "pseudo-operators" return the value of the last sub-expression, and binds tighter than parens, I can't actually remember seeing any one relying on grouping expressions with (), though, which is probably just as well. (I'm sure someone will now come up with an "essential" use of it)