-----Messaggio originale-----
Da: Chad Perrin [mailto:code / apotheon.net] 
Inviato: luned5 dicembre 2011 21:01
A: ruby-talk ML
Oggetto: Re: black magical hash element vivification

On Tue, Dec 06, 2011 at 01:39:54AM +0900, Adam Prescott wrote:
> D'oh! Strike that, it's behaving as expected, it's just hidden beneath n extra layer of oddness.
> 
> >> foo = Hash.new(Hash.new)
> => {}
> >> foo[3][2] = true
> => true
> 
> There's no assignment for the top-level hash. So the default hash 
> object specified in Hash.new(Hash.new) has been modified, but you 
> can't see it directly because you don't do, e.g., foo[3]=.

That, for me, is *very* surprising behavior.  I would think that it should
treat the default as though it exists, even when not referencing it
directly.


 
 
 --
 Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f
 
 Sponsor:
 Riccione Hotel 3 stelle in centro: Pacchetto Capodanno mezza pensione, animazione bimbi, zona relax, parcheggio. Scopri l'offerta solo per oggi...
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid982&d)-12