On Dec 28, 10:49=A0pm, Rimantas Liubertas <riman... / gmail.com> wrote:
> > #dup creates a copy of an object with a different object_id. As
> > follows:
>
> <=85>
>
>
>
>
>
> >> a =3D ["bar", "baz"]
> =3D> ["bar", "baz"]
> >> b =3D a.dup
> =3D> ["bar", "baz"]
> >> c =3D Marshal.load(Marshal.dump(a))
> =3D> ["bar", "baz"]
> >> b[0] << "s"
> =3D> "bars"
> >> b
> =3D> ["bars", "baz"]
> >> a
> =3D> ["bars", "baz"]
> >> c
> =3D> ["bar", "baz"]
> >> a.object_id
> =3D> 2157344160
> >> b.object_id
> =3D> 2157338800
> >> c.object_id
> =3D> 2157328340
> >> a[0].object_id
> =3D> 2157344140
> >> b[0].object_id
> =3D> 2157344140
> >> c[0].object_id
>
> =3D> 2157328320
>
> Regards,
> Rimantas
> --http://rimantas.com

This is in effect the deep copy of a complex array containing strings
that we were pining for. I think it is easier to do it this ways than
to map through all of the nested arrays. Thanks for the irb demo of
its use.