From: Paul Date: 2007-01-20T06:55:05+09:00 Subject: Bug in Ruby with adding strings? I just found what looks like a bug in Ruby 184-20. (I haven't tried it in newer builds.) Here's a simple script that will expose this bug: ---- irb(main):001:0> x = 1 => 1 irb(main):002:0> puts 'foo' + x.to_s +'bar' SyntaxError: compile error (irb):2: syntax error puts 'foo' + x.to_s +'bar' ^ from (irb):2 ---- I finally figured out that it was the Plus sign *right next* to the "bar", *after* the "to_s" method that Ruby dislikes. If I insert a space, I get the correct output. If I take out both spaces, I get the correct output. It's only if there's a space after the "to_s" and none between the Plus sign and string-in-quotes that it blows up. That is: > puts 'foo' + x.to_s + 'bar' # this works > puts 'foo' + x.to_s +'bar' # doesn't work > puts 'foo' + x.to_s+ 'bar' # this works > puts 'foo' + x.to_s+'bar' # this works Anyone know why this might be? I haven't played with it anymore, so I wonder if this bug exists with other methods. Paul