Ruby: merge two hash as one and with value connected

Posted by scalalala on Stack Overflow See other posts from Stack Overflow or by scalalala
Published on 2010-05-20T05:51:41Z Indexed on 2010/05/20 6:00 UTC
Read the original article Hit count: 139

Filed under:
|
|

Hi guys:

2 hash:

h1 = { "s1" => "2009-7-27", "s2" => "2010-3-6", "s3" => "2009-7-27" }

h2 = { "s1" => "12:29:15", "s2" => "10:00:17", "s3" => "12:25:52" }    

I want to merge the two hash as one like this:

h = { "s1" => "2009-7-27 12:29:15",
      "s2" => "2010-3-6 10:00:17", 
      "s3" => "2009-7-27 2:25:52" }

what is the best way to do this? thanks!

© Stack Overflow or respective owner

Related posts about ruby

Related posts about hash