On Tue, Sep 18, 2012 at 12:19 PM, Hans Mackowiak <[email protected]> wrote:
> when you only have a flat array, you could do:
> b = a.map(&:clone)
>
> but beware, some objects like fixnumbers dont want to be cloned

Well, you can do

b = a.map {|x| x.clone rescue x}

But that is still not a deep copy - unless types of objects in a
implement deep copy in their #clone method.

Kind regards

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.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