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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:13:56+00:00 2026-06-08T19:13:56+00:00

In Ruby, my understanding is that self is the implied receiver for any bare

  • 0

In Ruby, my understanding is that self is the implied receiver for any bare method call. However:

~: irb
>> puts "foo"
foo
=> nil
>> self.puts "foo"
NoMethodError: private method `puts' called for main:Object

What explains this?

In case it’s any help:

>> method(:puts).owner
=> Kernel
  • 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-08T19:13:57+00:00Added an answer on June 8, 2026 at 7:13 pm

    Private methods can’t have a receiver

    I think the answer is this: Ruby’s way of enforcing method privacy is that it doesn’t allow calling private methods with an explicit receiver.

    An example:

    class Baker
      def bake_cake
        make_batter
        self.use_oven # will explode: called with explicit receiver 'self'
      end
    
      private
      def make_batter
        puts "making batter!"
      end
    
      def use_oven
        puts "using oven!"
      end
    
    end
    
    b = Baker.new
    b.bake_cake
    

    Since there can be no explicit receiver, you certainly can’t do b.use_oven. And that is how method privacy is enforced.

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

Sidebar

Related Questions

Ruby has a select method that takes an array and returns a subarray consisting
My understanding is that count and length should return the same number for Ruby
It's my understanding that there's no bridge between Ruby and Perl to let you
I was under the impression that obj.method caused ruby to look for method thusly:
My understanding was that ruby blocks have block scope, and all variables created inside
i want to download ruby on rails, but i am not understanding what to
Ruby compacts the sequence only if it has nil value, how do I compact
Ruby tempfile instances automatically delete their corresponding file when the references are released. However,
I understand that method_missing is something of a last resort when Ruby is processing
I'm going through the tutorial Bastards Book of Ruby and I'm having trouble understanding

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.