From: David Vallner Date: 2007-02-19T23:16:14+09:00 Subject: Re: Why should initialize_copy verify the class of the original? On Sun, 18 Feb 2007 17:10:06 +0100, Jeremy Henty wrote: > I was looking at the CD player example in the Pickaxe book and I can't > see why their C implementation of CDPlayer#initialize_copy needs to > check that the original object is an instance of CDPlayer . Isn't > this always the case? If #initialize_copy is only called from inside > #dup or #clone then surely the receiver has to be of the same class as > the original! What am I missing? > CDPlayer.new.instance_eval {initialize_copy(TeddyBear.new)} Which would probably cause the C implementation to do Bad Things without said check. David Vallner