Ben Bleything
1/28/2009 7:21:00 PM
On Wed, Jan 28, 2009 at 11:07 AM, Bryson Smith <bryson@mailinator.com> wrote:
> Do I need to write my own function to parse through each hash's keys?
> Is there a built-in way to do this?
You can try Hash#merge:
irb(main):007:0> a = {:a => 1}
=> {:a=>1}
irb(main):008:0> b = {:b => 2}
=> {:b=>2}
irb(main):009:0> c = a.merge( b )
=> {:a=>1, :b=>2}
Note that if you have duplicate keys, the values in b will override
the values in a.
Ben