Ruby string pass by reference function parameter
<p>Ruby noob here</p>

<p>I understand ruby does pass by reference for function parameters</p>

<p>However, I am getting the feeling this is slightly different from conventional c/c++ style pass by reference</p>

<p>Sample code:</p>

<pre><code>def test1(str)
    str += ' World!'
end

def test2(str)
    str &lt;&lt; ' World!'
end

str = 'Hello'

test1(str)
p str # Hello

test2(str)
p str # Hello World!
</code></pre>

<p>I would expect <code>test1</code> to also return <code>Hello World!</code> if I were using references in c/c++.</p>

<p>This is simply out of curiosity -- any explanations would be appreciated</p>