From: Lyle Johnson Date: 2002-08-07T12:23:12+09:00 Subject: Re: Dup and Clone "Justin Johnson" wrote in message news:3d50209c$1_9@news5.nntpserver.com... > Could anyone kindly point out the difference between 'dup' and 'clone'? As has been noted in other responses, they're both kinds of "shallow" copies. The primary difference is that 'clone' copies an object's *entire* state, including its freeze status and instance variables, whereas 'dup' only copies the basic object contents. Why this distinction? That is a dandy question that I can't answer. Nevertheless, here's a quickie, meaningless example of the dynamic duo: s1 = "This is a string" class << s1 def foo=(f) @foo = f end def foo @foo end end s1.foo = 2 s1.freeze s1_clone = s1.clone s1_clone.frozen? --> returns true s1_clone.foo --> returns 2 s1_dup = s1.dup s1_dup.frozen? --> returns false s1_dup.foo --> error, basic String class doesn't have a "foo" method Hope this helps, Lyle