Are Strings mutable in Ruby? According to the documentation doing
str = "hello"
str = str + " world"
creates a new string object with the value "hello world"
but when we do
str = "hello"
str << " world"
It does not mention that it creates a new object, so does it mutate the str
object, which will now have the value "hello world"
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…