3 ms·
As a comparison, in Ruby puts "a" "b" == "ab" # true and puts "a" "b" == "ab" prints "a" with "b" == "ab" evaluated to false and discarded. This cou
by pmontra 5y ago
As a comparison, in Ruby
puts "a" "b" == "ab" # true
and
puts "a"
"b" == "ab"
prints "a" with "b" == "ab" evaluated to false and discarded. This could create bugs as with Python. However
["a"
"b"] == ["ab"]
is syntax error at the beginning of the second line. The parser expects a ]
It would evaluate to true if it were on one line.
- grey-area 5y agoIn Ruby one too many commas can also cause problems: # list list = "a","b", # function def foobar end => ["a", "b", :foobar]
- int_19h 5y agoI actually prefer Python approach here in that within () [] {} newlines are simply whitespace with no special meaning - this allows for very flexible formatting of expressions which is still unambiguous. The implicit concat of string literals is the culprit here. It really should require "+".