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 7645975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:05:13+00:00 2026-05-31T10:05:13+00:00

I have: a = [{:a=1,b=2,:c=3},{:a=4,:b=5,:c=6},..] (including 2 items with 3 keys) b = [{:d=7},{:d=8},…]

  • 0

I have:
a = [{:a=1,"b=2,:c=3},{:a=4,:b=5,:c=6},..] (including 2 items with 3 keys)
b = [{:d=7},{:d=8},...] (including 2 items with 1 key)

At final I need to have 2 items with 4 keys:
a = [{:a=1,:b=2,:c=3,:d=7},{:a=4,:b=5,:c=6,:d=8},..]

Please help, tried to do the following:

a.each do |item|
   b.each do |view|
     item.merge!(view)      
   end
end

But at final I have in two items the same dates as for item one in array b (d=7).

  • 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-05-31T10:05:15+00:00Added an answer on May 31, 2026 at 10:05 am

    First of all your definitions of a and b are not very valid. You need to use either symbols or strings a is not a valid key for a hash. Also you should use => to point a key to value.
    Here is how you can achieve what you want to do:

    a = [{:a=>1,:b=>2,:c=>3},{:a=>4,:b=>5,:c=>6}]
    b =[{:d=>7}, {:d=>8}]
    a.zip(b) do |x,y|
      x.merge!(y)
    end
    

    Zip performs the operation on each matching pair of elements in a and b – precisely what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list, each item of which has several things in it, including
I have tried all the solutions that have been provided including using PRAGMA but
Let us suppose I have a todolist, each line including the same structure of
I have two lists that contain many of the same items, including duplicate items.
Does RSS/Atom have a semi-official method of including active (read:javascript) content in it's items?
I have a list of items in one view controller. I can select an
To explain the domain... I have a bunch (1,000,000) of items, each of a
I have a MySQL(innodb) table 'items' with the following characteristics Large number of rows,
I have a list of items, instances of a Item class saved in a
I have main.cpp (including main function) and func1.cpp, and I want to link these

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.