Sind Strings in Ruby veränderbar?

Sind mutable Strings in Ruby? Nach der Dokumentation tun

str = "hello"
str = str + " world"

erstellt ein neues string-Objekt mit dem Wert "hello world" aber wenn wir es tun

str = "hello"
str << " world"

Er erwähnt nicht, dass es ein neues Objekt erstellt, so tut es mutieren die str Objekt, welches nun den Wert "hello world"?

InformationsquelleAutor der Frage Aly | 2011-04-16

Schreibe einen Kommentar