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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:54:12+00:00 2026-05-14T05:54:12+00:00

I would like to understand what class << self stands for in the next

  • 0

I would like to understand what class << self stands for in the next example.

module Utility
  class Options #:nodoc:
    class << self
      def parse(args)          
      end
    end
  end
end
  • 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-14T05:54:13+00:00Added an answer on May 14, 2026 at 5:54 am

    this

    module Utility
      class Options #:nodoc:
        class << self
          # we are inside Options's singleton class
          def parse(args)
    
          end
        end
      end
    end
    

    is equivalent to:

    module Utility
      class Options #:nodoc:
        def Options.parse(args)
    
        end
      end
    end
    

    A couple examples to help you understand :

    class A
      HELLO = 'world'
      def self.foo
        puts "class method A::foo, HELLO #{HELLO}"
      end
    
      def A.bar
        puts "class method A::bar, HELLO #{HELLO}"
      end
    
      class << self
        HELLO = 'universe'
        def zim
          puts "class method A::zim, HELLO #{HELLO}"
        end
      end
    
    end
    A.foo
    A.bar
    A.zim
    puts "A::HELLO #{A::HELLO}"
    
    # Output
    # class method A::foo, HELLO world
    # class method A::bar, HELLO world
    # class method A::zim, HELLO universe
    # A::HELLO world
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use a class attribute as a default value for one
I have a winform with a form called MainForm. I have a static class
I have a message bus, and a class subscribes many methods to the message
I understand that we're supposed to avoid putting logic in the controller. So what
I have two ActiveRecord classes. A simplified view of these classes: class Account <
Another question provides a nice, simple solution for implementing a test for equality of
I am trying to determine the recommended way to set default values for NSString
Is there a way to automatically start the debugger at the point at which
I have a reasonably complex custom Django model method. It's visible in the admin
Ok, here goes. Being a Java developer I'm still struggling with the memory management

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.