[#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: Alexander Bokovoy <a.bokovoy@...>
Date: 2004-02-20 12:56:34 UTC
List: ruby-core #2478
On Fri, Feb 20, 2004 at 08:54:31PM +0900, Yukihiro Matsumoto wrote:
> Hi,
> 
> In message "PATCH: OpenStruct#initialize to yield self"
>     on 04/02/19, Gavin Sinclair <gsinclair@soyabean.com.au> writes:
> 
> |This is a common approach I use to object initialization; I don't know
> |about other people.  Thought it was worth mentioning it here.  It
> |allows code like the following:
> |
> |  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?
Atomicity? Ability to return nil as 'r' in case of failure of complex
initialization?
-- 
/ Alexander Bokovoy
Samba Team                      http://www.samba.org/
ALT Linux Team                  http://www.altlinux.org/
Midgard Project Ry              http://www.midgard-project.org/

In This Thread