From: "Mauricio Fernández" Date: 2003-05-21T19:03:57+09:00 Subject: Re: Copying an Array On Wed, May 21, 2003 at 05:56:37PM +0900, Robert Klemme wrote: > > You want a deep copy of a nested array structure. As easy as that: > > module Enumerable > def deep_copy > map {|x| x.respond_to?( :deep_copy ) ? x.deep_copy : x} > end > end Try this: batsman@tux-chan:~/src/ctl$ ruby module Enumerable def deep_copy map {|x| x.respond_to?( :deep_copy ) ? x.deep_copy : x} end end a = [] b = [a] a << b p a.deep_copy ^D ==> hangs It's safer to use Marshal... -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Save yourself from the 'Gates' of hell, use Linux." -- like that one. -- The_Kind @ LinuxNet