------art_6364_20368467.1190793406918
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On 9/26/07, Daniel Sheppard <daniels / pronto.com.au> wrote:
>
> > > myhash  }
> > > key.zip(value) {|a,b| myhash[a]   }
> > >
> > > It does not work!
> > irb(main):017:0> key.zip(value){|a,b| myhash[a]  }
> > nil
>
> The result is in my_hash
>
> irb(main):014:0> myhash  }
> {}
> irb(main):015:0> key.zip(value) {|a,b| myhash[a]   }
> nil
> irb(main):016:0> myhash
> {"1"a", "2"b", "3"il}
>
>
Thanks a lot! By the way, what is the different between special case and
general case?

For the special case where key and value do not contain arrays:

Hash[*key.zip(value).flatten]

For the general case:

myhash  }
key.zip(value) {|a,b| myhash[a]   }

Dan


-- 
Best Regards
Cooper Geng

------art_6364_20368467.1190793406918--