From: dblack@... Date: 2003-03-29T00:54:35+09:00 Subject: Re: Newbie question:Does Ruby have the structure of hash's array like Perl does? Hi -- On Fri, 28 Mar 2003, Brett H. Williams wrote: > It looks like the block form gives you a new object each time to > return when a key doesn't exist in the hash, but it doesn't assign > that as the value of the key. Is that correct?: Yes; the default value for a hash is what you get for non-existent keys, with no assignment implied, and the block form is just an recent extension of that behavior. It does lead to some interesting constructs: h = Hash.new { [] } h[1] = h[1] # not a sight you see often! h[2].id == h[2].id # false and one of my favorites: h = Hash.new { raise "Access denied!" } :-) David -- David Alan Black home: dblack@superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav