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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:56:47+00:00 2026-05-25T16:56:47+00:00

This is what I’ve been getting: {:user=>{:employees=>{…}, :login=>dernalia, :id=>1, :role=>2}} What is generating the

  • 0

This is what I’ve been getting:

{:user=>{:employees=>{...}, :login=>"dernalia", :id=>1, :role=>2}}

What is generating the hash:

  def management_tree(args = {})
    args = {:users => [], :result => {}}.merge(args) #defaults
    result = args[:result]

    if not args[:users].include? self.login #prevent duplicates
      result.merge!({:user => {:id => self.id, 
                              :login => self.login,
                              :role => self.role,
                              :employees => employee_tree(args[:users] + [self.login], args[:result])
                              }
                    })      

    end
    logger.info result.inspect
    return result
  end

  def employee_tree(users, result)
    if self.employees.length > 0
       self.employees.each {|emp| (emp.management_tree({:users => users, :result => result})) }
    end
    return result
  end

Now… it’s supposed to return something like this:

{:user=>{:login=>"me", :id=>1, :role=>2, 
        :employees=>{
             :user => {:login => "2", ...},
             :user => {:login => "3",
                   :employees => {...}
         }

}}

Some console output:

% bundle exec script/console
Loading development environment (Rails 2.3.8)
>> require "awesome_print"
=> []
>> ap User.find(1).management_tree[:employees]
nil
=> nil
>> ap User.find(1).management_tree
{
    :user => {
        :employees => {...},
             :role => 2,
            :login => "me",
               :id => 1
    }
}
=> {:user=>{:employees=>{...}, :role=>2, :login=>"me", :id=>1}}
>> 

now… it says that employees is nil… but it shouldn’t be… it should have 3 hashes … =\

but also, what does {…} mean? it seams terribly ambiguous

  • 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-25T16:56:47+00:00Added an answer on May 25, 2026 at 4:56 pm

    Ruby is clever about recursive structures and will use "..." instead of looping indefinitely.

    For example:

    a = [1, 2]
    a << a # a is now recursive, since it contains itself
    a.to_s # => [1, 2, [...]]
    a[2][2][2][2][2][2][2] == a # => true
    

    In your case, the {...} refers to any of the hashes already in the process of being outputed.

    Maybe what you meant to do was to insert a copy of a hash? In the simple array example:

    a = [1, 2]
    a << a.dup # a is not recursive
    a.to_s # => [1, 2, [1, 2]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
This question is quite specific. I'm using Symfony2 White October Admin Bundle for generating
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This problem has been bugging me since forever. I have an array and in
This question has been asked in various permutations, but I haven't found the right
This question has been asked before but that was three years ago and Microsoft
This is a bit of a long shot, but if anyone can figure it
This is starting to vex me. I recently decided to clear out my FTP,
This is kinda oddball, but I was poking around with the GNU assembler today
This might seem like a stupid question I admit. But I'm in a small

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.