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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:04:31+00:00 2026-06-17T23:04:31+00:00

I need to run multiple methods from an array like the folowing example, first

  • 0

I need to run multiple methods from an array like the folowing example, first approach works but i’d rather let just run the methods without displaying the result. How to adapt the second approach so that i don’t get the error below ?

def method1
  print 1
end

def method2
  print 2
end

[method1, method2].each(&p) #=>12 (works)

[method1, method2].each(&method(:run)) 
#=>12 `method': undefined method `run' for class `Object' (NameError)
  • 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-17T23:04:32+00:00Added an answer on June 17, 2026 at 11:04 pm

    Because method1 invokes the method (rather than referring to it), your arrays actually contain the results of running the methods, not references to the methods themselves.

    You probably want:

    [:method1, :method2].each {|m| method(m).call}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Requirement: I need to run multiple animations one by one. I'm using onAnimationEnd() to
I need my application run in multiple screen resolutions. Currently I have specified all
Do I need to have separate/multiple workers to run multiple websites (each with a
How to I run multiple threads in VB.NET? Say I need 2 threads -
I need to run an executable JAR file in multiple threads/cores. The JAR file
I need run ts:reindex when smth add in model or destroy from model. How
I need to access the goToTop and discCrop method from multiple classes, and since
I need to delete multiple rows from my database table. This is my code
I need to stop user making multiple clicks on a JButton while the first
i need run code that will create a database and populate tables. i am

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.