标签: ruby string
如果我有这段代码:
a = "hi" "pie" puts a
它将打印出hipie。 Ruby会自动组合这些吗?
hipie
答案 0 :(得分:6)
是。来自Literals: String
相邻的字符串文字由解释器自动连接: "con" "cat" "en" "at" "ion" #=> "concatenation" "This string contains " "no newlines." #=> "This string contains no newlines."
相邻的字符串文字由解释器自动连接:
"con" "cat" "en" "at" "ion" #=> "concatenation" "This string contains " "no newlines." #=> "This string contains no newlines."