[#2367] Standard libraries — Dave Thomas <dave@...>

From ruby-dev summary:

60 messages 2004/02/11

[#2397] PATCH: deprecate cgi-lib, getopts, importenv, parsearg from standard library — Gavin Sinclair <gsinclair@...>

Index: cgi-lib.rb

15 messages 2004/02/12

[#2465] PATCH: OpenStruct#initialize to yield self — Gavin Sinclair <gsinclair@...>

This is a common approach I use to object initialization; I don't know

24 messages 2004/02/19

Re: PATCH: OpenStruct#initialize to yield self

From: Joel VanderWerf <vjoel@...>
Date: 2004-02-21 02:24:01 UTC
List: ruby-core #2489
J.Herre wrote:

> What's the point of?
> 
> |  OpenStruct.new do |r|
> |    r.name = 笛ohn Smith> |    r.age = 70
> |    r.pension = 300
> |  end
> 
> ie, constructing an orphaned obj

Nothing, in the case of OpenStruct, but another class's initialize 
method might do all the work of the object (e.g. create a file, or start 
a process), after which you don't want it any more. You only want to 
access the object _while_ you are configuring it in the initialize 
block, after which #initialize goes off and does something with your 
configuration. But this is a peculiar kind of class. Better design would 
be a class method which yields a config object.

In This Thread