Ruby - local variable gets modified when changing instance variable
<p><code>temp</code> gets <code>@board.dup</code>, and <code>@board</code> array is modified. However, <code>temp</code> gets modified as well! I have tried reading all the related documentations but still couldn't figure out an explanation.</p>

<pre><code>class Test
    def initialize
        @board = [[1,2],[3,4], [5,6]]
    end

    def modify
        temp = @board.dup #Also tried .clone

        print 'temp: ';p temp
        print '@board: ';p @board

        @board.each do |x|
            x &lt;&lt; "x"
        end

        print "\ntemp: ";p temp
        print '@board: ';p @board
    end
end

x = Test.new
x.modify
</code></pre>

<p>Output:</p>

<pre><code>temp: [[1, 2], [3, 4], [5, 6]]
@board: [[1, 2], [3, 4], [5, 6]]

temp: [[1, 2, "x"], [3, 4, "x"], [5, 6, "x"]] # &lt;= Why did it change?
@board: [[1, 2, "x"], [3, 4, "x"], [5, 6, "x"]]
</code></pre>

<p>What can I do to ensure temp doesn't get modified?</p>