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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:42:20+00:00 2026-05-26T18:42:20+00:00

in the rails source : https://github.com/rails/rails/blob/master/activesupport/lib/active_support/lazy_load_hooks.rb the following can be seen @load_hooks = Hash.new

  • 0

in the rails source : https://github.com/rails/rails/blob/master/activesupport/lib/active_support/lazy_load_hooks.rb

the following can be seen

@load_hooks = Hash.new {|h,k| h[k] = [] }

Which in IRB just initializes an empty hash. What is the difference with doing

@load_hooks = Hash.new
  • 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-26T18:42:21+00:00Added an answer on May 26, 2026 at 6:42 pm

    Look at the ruby documentation for Hash

    new → new_hash click to toggle source
    new(obj) → new_hash
    new {|hash, key| block } → new_hash

    Returns a new, empty hash. If this hash is subsequently accessed by a key that doesn’t correspond to a hash entry, the value returned depends on the style of new used to create the hash. In the first form, the access returns nil. If obj is specified, this single object will be used for all default values. If a block is specified, it will be called with the hash object and the key, and should return the default value. It is the block’s responsibility to store the value in the hash if required.
    Example form the docs

    # While this creates a new default object each time
    h = Hash.new { |hash, key| hash[key] = "Go Fish: #{key}" }
    h["c"]           #=> "Go Fish: c"
    h["c"].upcase!   #=> "GO FISH: C"
    h["d"]           #=> "Go Fish: d"
    h.keys           #=> ["c", "d"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this rails app: https://github.com/ryanb/govsgo/blob/master/app/views/authentications/index.html.erb There is a form that as 'new_user_path' Where is
I have the following gemfile: source 'http://rubygems.org' source 'http://gems.engineyard.com' gem 'rails', '~> 3.1.0.rc4' gem
I am trying to install the gem from https://github.com/raid5/paths_of_glory/tree/rails3 When I put the following
Does the acts-as-readable plugin work for rails 3? The instructions at https://github.com/mbleigh/acts-as-readable results in
I want to do this: https://github.com/rails/rails/commit/f50aeda2f73b47c47664e3651c638ba624418b8b See how, as your mouse cursor moves over
UPDATE 9th june 2012: Setup with mongoid 3.0.0.rc at heroku, see this gist: https://gist.github.com/2900804
I'm following a tutorial http://fuelyourcoding.com/getting-started-with-jquery-mobile-rails-3/ transforming the views in a straightforward scaffolded Rails 3
I am specifically intertested in #270. You can see it here: http://railscasts.com/episodes/270-authentication-in-rails-3-1 I've downloaded
I'm trying to replace fixture generation with factories using rails3-generators: https://github.com/indirect/rails3-generators#readme The gem is
I followed these steps on https://github.com/karmi/tire to install elasticsearch for use with ruby on

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.