From: "David A. Black" Date: 2008-04-23T05:12:25+09:00 Subject: Re: Hashes Hi -- On Wed, 23 Apr 2008, Tim Wolak wrote: > >> I didn't realize this before, but even if it's off topic, I thought >> I'd bring it up. >> >> Hashes -- during creation -- allow assignment more than once in 1.8.6 >> with the last one taking precedence >> >> Is that somehow common knowledge that I missed in the Pickaxe? Just >> one of those little things, I guess. >> >> irb(main):002:0> h = {[1, 2, 3] => [4, 5, 6], [1, 2, 3] => [7, 8, 9]} >> => {[1, 2, 3]=>[7, 8, 9]} >> >> Todd >> > Ouch, I guess that would be a bad thing... If I'm going line by line then I > would think I would be ok then as the hash is closed after I finish to take > on the next line correct? It's never exactly closed, in that sense. Hash keys are unique, so if you key a new value, you lose the old value, even if it's not at the time that the hash is created. If your keys are account numbers and your values are arrays of balances, you'll be all right as long as you don't trample the arrays -- just add to them. David -- Rails training from David A. Black and Ruby Power and Light: INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin INTRO TO RAILS June 24-27 London (Skills Matter) See http://www.rubypal.com for details and updates!