为什么 ruby 会自动组合字符串?
Why does ruby automatically combine Strings?
如果我有这个代码:
a = "hi" "pie"
puts a
它会打印出hipie
。 Ruby 会自动组合这些吗?
是的。来自 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."
如果我有这个代码:
a = "hi" "pie"
puts a
它会打印出hipie
。 Ruby 会自动组合这些吗?
是的。来自 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."