From: botp Date: 2008-02-20T10:26:47+09:00 Subject: Re: String Concatenation and Implicit Object Creation From: pachl [mailto:clintpachl@gmail.com] # Do adjacent strings or strings separated by backslash and a newline # create multiple String objects? iianm, no. you create just one string literal, ergo one string object. it's part of ruby syntax on string literals. very useful if you want to emphasize a string part, similar to numeric literals where you can put underscore to separate some digits... # For example: s1 = 'asdf' 'qwer' #=> "asdfqwer" # here string literal processing continues s2 = 'asdf'\ 'qwer' #=> "asdfqwer" # here too s1 = 'asdf' 'qwer' "#{s2}" # still inline works #=> "asdfqwerasdfqwer" s1 = 'asdf' 'qwer' s2 # this one errs, ruby expect all literals SyntaxError: compile error (irb):13: syntax error, unexpected tIDENTIFIER, expecting $end from (irb):13 from :0 s1 = 'asdf' + 'qwer' + s2 #=> "asdfqwerasdfqwer" it may look like concat op, s1 = 'asdf' 'qwer' + s2 #=> "asdfqwerasdfqwer" but... s1 = 'asdf' ('qwer' + s2) SyntaxError: compile error (irb):17: syntax error, unexpected '(', expecting $end s1 = 'asdf' ('qwer' + s2) ^ from (irb):17 from :0 s1 = ('asdf' 'qwer') + s2 #=> "asdfqwerasdfqwer" kind regards -botp