Both variables point to the same array.

If you want two arrays, you need to call #dup:

arr2 = arr1.dup

--
Avdi Grimm
http://avdi.org
On Jul 13, 2012 11:43 PM, "Mike Onofrietto" <[email protected]> wrote:

> Hello all,
>
> Need help.
> See code below. The array arr2  has data to start with.
> The first 2 puts show output - no problem - both the same as expected.
>
> The last 2 puts - no output - nothing - nada.
>
> Between the lines shown here there is no other code - this is exactly
> what the actual code looks like.
>
> puts "        #{arr2}"
> arr1 = arr2
> puts "        #{arr1}"
>
> arr2.clear
> puts "        #{arr1}"
> puts "        #{arr2}"
>
> --
> Posted via http://www.ruby-forum.com/.
>
>

-- You received this message because you are subscribed to the Google Groups 
ruby-talk-google group. To post to this group, send email to 
[email protected]. To unsubscribe from this group, send email 
to [email protected]. For more options, visit this 
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en

Reply via email to