From: matz@... (Yukihiro Matsumoto) Date: 2003-08-13T02:47:01+09:00 Subject: Re: common constructor idioms Hi, In message "common constructor idioms" on 03/08/13, Scott Thompson writes: |In C++ one often declares a constructor that accepts another instance |of this class. For those familiar with C++ syntax I'm talking about: | |class MyClass { | /* other interesting stuff in this class deleted */ | | /* Copy constructor */ | MyClass(const MyClass &objectToCopy); |}; | |I guess you could do something similar in Ruby like this: | |class MyClass | def initialize(x) | if x.class == MyClass then | #some code to duplicate stuff in x | else | #potentially other initialization mechanisms here | end | end |end How about leaving "initialize" for basic initialization, and define class methods for each object construction scheme, with proper names? matz.