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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:52:29+00:00 2026-06-18T05:52:29+00:00

I know of two ways ruby allows static functions to call each other within

  • 0

I know of two ways ruby allows static functions to call each other within the same class…

class MyClass

  def self.foo
    self.say "self"
  end

  def self.bar
    MyClass.say "class name"
  end

  def self.say(text)
    puts "Using #{text}"
  end

end

Are there any subtle differences between the two syntaxes? Maybe performance?

  • 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-18T05:52:30+00:00Added an answer on June 18, 2026 at 5:52 am

    No, those are exactly the same. Performance-wise too. The only difference is code maintainability. If you decide to move a method with explicit class reference to another class, there’s more work for you (or less, depending on a situation)

    def self.bar
      MyClass.say "class name"
    end
    

    Oh, and there are no static methods in ruby.

    Also, you don’t need to explicitly use self to call a method there. self can be implicit.

    class MyClass
    
      def self.foo
        say "self"
      end
    
      def self.say(text)
        puts "Using #{text}"
      end
    
    end
    
    MyClass.foo
    # >> Using self
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$.each(obj,function(key,value) {}) I am a newbie of jquery, i know there are two ways
So far I know two ways to pass php variables to javascript. One is
I know of two ways of creating custom JSF components: 1. Native JSF way:
I know two ways to save/load application settings: use PersistentStore use filesystem (store, since
I know of two ways to delete data from a database table DELETE it
As far as i know the two ways to get mouse position are using
I am a little confused in declaring variable in android, I know two ways
Currently I know of only two ways to cache data (I use PHP but
There are at least two ways that I know of to write a Symbian
So I've noticed that there seem to be two ways to get the same

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.