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 On Jul 1, 2:52 am, DGerton <dger...@gmail.com> wrote:> 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?
On Tue, Jun 30, 2009 at 3:14 PM, mynyml<martin.aumont@gmail.com> wrote:> > 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.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})" -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale