[#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: "J.Herre" <jlst@...>
Date: 2004-02-21 01:55:41 UTC
List: ruby-core #2485
On Feb 20, 2004, at 4:33 PM, Joel VanderWerf wrote:

>> |  record = OpenStruct.new do |r|
>> |    r.name = "John Smith"
>> |    r.age = 70
>> |    r.pension = 300
>> |  end
>> How much benefit do you get from this than
>>   r = OpenStruct.new
>>   r.name = "John Smith"
>>   r.age = 70
>>   r.pension = 300
>> ?  Bit of readability?
>
> Someone mentioned before that it lets you construct an object that can 
> be GC-ed as soon as initialize is done. FWIW.
>

Neither of these cases would gc until the local went out of scope or 
was cleared?  What am I missing?

In these case that you don't really want what your creating wouldn't
    OpenStruct.new
be more efficient than
    OpenStruct.new {}
anyway?


In This Thread