From: matz@... (Yukihiro Matsumoto) Date: 2000-09-01T09:04:51+09:00 Subject: [ruby-talk:4711] Re: new, initialize, etc. Hi, In message "[ruby-talk:4705] new, initialize, etc." on 00/09/01, hal9000@hypermetrics.com writes: |As I see it, new is typically a class method which invokes the |initialize method. | |First of all, why? I guess I can understand new being a class method, |but why is initialize named differently? Why not just define new for |the class and put the initializing code in there? As Dave explained in [ruby-dev:4707], the instance creation is done in two steps. Why? Because the `new' class method does not have special privilege to access internal of the object. It's naturally done by the instance method (initialize) to initialize the object, |Second, I've read a little about finalizing objects; I'm not sure why |or when to do it. And why do it that way, rather than just provide a |method to be called by the GC when the object dies? A finalizer like Java (a method to be called by GC) may "resurrect" the unreferenced object. It may result performance drawback. |Finally, how are BEGIN and END supposed to be used? I've read what they |do -- it seems to me they would be useful for modules -- but I don't |actually grasp them. Are they completely unrelated to the concept of |creating and destroying objects? It's handy with -n/-o option for the interpreter. matz.