It depends on the fact that white spaces can be significant in Ruby. You see different results, because Ruby interprets your example differently. So
First:
"ayay".length + 1
looks like
"ayay".length.+(1)
And the second:
"ayay".length +1
looks like
"ayay".length(+1)
This way you can understand why Ruby gives an error in the second case.
Regarding the count problem: Ruby interprets the code as:
User.count(+1)
And, as you can see from the generated SQL, there is a difference, because +1
is considered the column_name parameter.
source share