Comment on Never create Ruby strings longer than 23 charactersparentComments−charliesome14yHere's a better explanation for #1:In Ruby, most classes (including String) are reference types. This is why `str2 = str` doesn't create a new string. It doesn't create a new RString either - str and str2 are both pointers to the same RString struct.
Comments
Here's a better explanation for #1:
In Ruby, most classes (including String) are reference types. This is why `str2 = str` doesn't create a new string. It doesn't create a new RString either - str and str2 are both pointers to the same RString struct.