The +
same as the -
in ruby are overloaded in order to make the syntax look nice.
When there is no space the Ruby parser recognizes the +
as the method which is called on the result of d6
which is an Integer
.
Same goes for the version with space before and after the +
.
However: In the operator precedence in Ruby +
as a unary operator is defined before +
as a binary operator (as is often the case in other languages as well).
Therefore if there is a space before the +
but not after it, the Ruby Parser will recognize it as d6(+2)
which fits the error message.