I can call initialize_copy too, here:

object.initialize_copy

Ha! I've fooled this object!

In Ruby, you can always do anything. No, really.

If $SAFE isn't used (which is mostly the case), every bit of code can
do ANYTHING to the program state.

So that initialize_copy sanity test makes sense (personally, I'm not
sure I would've done it, but it makes sense).


Plug: Check the adopt-a-newbie thread in ruby-talk.

On 2/18/07, Jeremy Henty <jeremy / chaos.org.uk> 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?
>
> Regards,
>
> Jeremy Henty
>
>