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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:59:46+00:00 2026-06-17T05:59:46+00:00

There is a code in ruby Dir.glob(my_folder/*.rb).each { |r| require_relative r} I almost understand

  • 0

There is a code in ruby

Dir.glob("my_folder/*.rb").each { |r| require_relative r}

I almost understand but I want to be sure why is the code below not working

Dir.glob("my_folder/*.rb").each(&:require_relative)

due to error of NoMethodError: private method require_relative' called for "my_folder/one.rb":String

Is this because

Dir.glob("controllers/*.rb").each(&:require_relative)

is equal to

Dir.glob("controllers/*.rb").each{ |r| r.require_relative }

?

  • 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-17T05:59:47+00:00Added an answer on June 17, 2026 at 5:59 am

    You are right, it is equivalent to

     .each{ |r| r.require_relative}
    

    & calls to_proc on an object, in this case, a symbol, and Symbol implements it and creates a new Proc, which does a call on the object.

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

Sidebar

Related Questions

I have to following code in ruby: <% files = Dir.glob('/**/*') files.each do |file|
I want to prevent my users to read my ruby code. Are there some
I'm writing a simple piece of code in ruby, but it's not working the
is there some ruby code I can use to install a gem from a
There is code for save button, but I can't see any code behind the
I'm reading some Ruby code and I don't understand this snippet: thing = '${other-thing}/etc/'
I am quite new to ruby but enjoying it so far quite immensely. There
Are there certain code conventions when documenting ruby code? For example I have the
My question is: is there some most efficient solution for this code in ruby
I'm not sure if there's something I did wrong here in some config files.

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.