Yes, strings in Ruby, unlike in Python, are mutable.
s += "hello"
is not appending "hello"
to s
- an entirely new string object gets created. To append to a string 'in place', use <<
, like in:
s = "hello"
s << " world"
s # hello world
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…