Why does ruby ​​automatically concatenate strings?

If I have this code:

a = "hi" "pie"
puts a

Will be printed hipie. Does Ruby automatically combine these features?

+3
source share
1 answer

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."
+6
source

Source: https://habr.com/ru/post/1570390/


All Articles