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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:44:59+00:00 2026-05-22T22:44:59+00:00

I do the following my_hash = Hash.new my_hash[:children] = Array.new I then have a

  • 0

I do the following

my_hash = Hash.new
my_hash[:children] = Array.new

I then have a function that calls itself a number of time each time writing to children

my_hash[:children] = my_replicating_function(some_values)

How do I write without overwriting data that is already written ?

This is what the entire function looks like

def self.build_structure(candidates, reports_id)
 structure = Array.new
 candidates.each do |candidate, index|
  if candidate.reports_to == reports_id
    structure = candidate
    structure[:children] = Array.new
    structure[:children] = build_structure(candidates, candidate.candidate_id)
  end
 end
 structure
end
  • 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-22T22:45:00+00:00Added an answer on May 22, 2026 at 10:45 pm

    Maybe this:

    structure[:children] << build_structure(candidates, candidate.candidate_id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The new hash syntax in Ruby 1.9.2 means that I can do the following:
I have a python hash that contains a mapping of function name to function.
I have a hash table with the following contents: my %hash = ( 'a'
Will the following function correctly hash my provided string? Or am I missing something
In my model i have the following bit of code. hash_values = JSON.parse(question_hash) hash_values.each
I have a Perl class that contains a hash instance variable for storing other
I am not sure what to call the following data structure: Hash or Array.
I am new to Gearman. I have following queries about optimized Gearman usages: 1)
I have a hash of AoAs: $hash{$key} = [ [0.0,1.0,2.0], 10.0, [1.5,9.5,5.5], ]; that
I have a script that utilizes a hash, which contains four strings as keys

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.