Possible parsing weirdness

I'm using rails 2.3.2 on MacOSX. This line throws an error: logger.info 'request is an email (' + email.to_s +')'

However, this line does not: logger.info 'request is an email (' + email.to_s + ')'

Notice the space in ...to_s + ')' The error is "syntax error, unexpected tUPLUS, expecting '}'." Putting in the curly braces doesn't help. As in... logger.info { 'request is an email (' + email.to_s +')' }

In the words of Goldmember, "Izant zat zweirds?"

Am I missing something or should I file a bug, and, if so, where?

In the spaceless version, it seems the + is being interpreted as a unary plus (tUPLUS), the result of which will be passed as argument to #to_s

With a simplified statement:

''.to_s +''

NoMethodError: undefined method `+@' for "":String

''.to_s + ''

=> ""

''.to_s() +''

=> ""

This is strictly Ruby behaviour though, not a Rails concern.

mynyml

And by the way, most rubyists would write this:

logger.info 'request is an email (' + email.to_s + ')'

using string interpolation:

logger.info "request is an email (#{email})"