3

If I have this code:

a = "hi" "pie"
puts a

It will print out hipie. Does Ruby automatically combine these?

FourScore
  • 171
  • 8
  • See also [Why do two strings separated by space concatenate in Ruby?](http://stackoverflow.com/q/23811203/1422127), [Strange string behavior in Ruby](http://stackoverflow.com/q/23206687/1422127), and [How String concatenation works in ruby?](http://stackoverflow.com/q/27763763/1422127). – Quip Yowert Jan 08 '15 at 02:47
  • Is the question whether it does so or why it does so? – sawa Jan 08 '15 at 03:12

1 Answers1

6

Yes. From Literals: String

Adjacent string literals are automatically concatenated by the interpreter:

"con" "cat" "en" "at" "ion" 
#=> "concatenation"
"This string contains " "no newlines."              
#=> "This string contains no newlines."
Yu Hao
  • 119,891
  • 44
  • 235
  • 294