Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8455013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:10:37+00:00 2026-06-10T12:10:37+00:00

I have following array of hashes: >> hash = { One => [{Oneone =>

  • 0

I have following array of hashes:

>> hash = { "One" => [{"Oneone" => "1", "Onetwo" => "2"}, {"Oneone" => "3", "Onetwo" => "4"}], "Two" => [{"Twoone" => "5", "Twotwo" => "6"}, {"Twoone" => "7", "Twotwo" => "8"}] }
{
    "One" => [
        [0] {
            "Oneone" => "1",
            "Onetwo" => "2"
        },
        [1] {
            "Oneone" => "3",
            "Onetwo" => "4"
        }
    ],
    "Two" => [
        [0] {
            "Twoone" => "5",
            "Twotwo" => "6"
        },
        [1] {
            "Twoone" => "7",
            "Twotwo" => "8"
        }
    ]
}

I would like to merge them to achieve this:

{
    "OneTwo" => [
        [0] {
            "Oneone" => "1",
            "Onetwo" => "2",
            "Twoone" => "5",
            "Twotwo" => "6"
        },
        [1] {
            "Oneone" => "3",
            "Onetwo" => "4",
            "Twoone" => "7",
            "Twotwo" => "8"
        }
    ]
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:10:38+00:00Added an answer on June 10, 2026 at 12:10 pm

    Assuming your example is representative of your data, this should work.

    Hash[hash.keys.join,
         hash.values.transpose.map { |hashes| hashes.inject &:merge }
        ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following array $data = array('key1'=>'val1', 'key2'=>'val2', 'key3'=>'val3' ); I would like
I have a perl hash of hashes like the following: $VAR1 = { 'ID_1'
I have taken following array; to fill-up gallery: private Integer[] mImageIds = { R.drawable.one,
I would like to initialize several auto-vivifying hashes by one-line expression. So far I
I have the following array of hashes, and want to remove the ones that
I have the following array of hashes: [{idx=>1234, account=>abde, money=>4.00, order=>00001}, {idx=>1235, account=>abde, money=>2.00,
I'm using Ruby 1.8.7. I have the following array of hashes. I need to
I have following array, that I need to operate by hand on bitmaps. const
I have the following array: $franchise_a_status[] = array( 'id' => $franchise['franchise_id'], 'text' => $franchise['franchise_surname'].
I have the following array(in python): arr= ['\n', ' a#B\n', ' c#D\n'] Now I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.