4 ms·
Is that allocating a new buffer, leaving the "hello" string to be collected by the GC?
by dbaupp 13y ago
Is that allocating a new buffer, leaving the "hello" string to be collected by the GC?
- tedunangst 13y agoNo, it expands the existing buffer. (leaving " world" to be collected). Note that the following is different and more like what you're thinking. a = a + " world"
- jeorgun 13y agoNo, it's operating in place: def append_world(str) str << " world" end a = "hello" append_world(a) a #=> "hello world"