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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:24:12+00:00 2026-06-03T16:24:12+00:00

It’s probably not a paradox at all, but from a newbies perspective, it sure

  • 0

It’s probably not a paradox at all, but from a newbies perspective, it sure seems that way.

> Class.superclass
=> Module
> Class.superclass.class
=> Class
> Class.superclass.class.superclass
=> Module

So a class’s parent is module, but module is a class?

How can I make sense of this?

  • 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-03T16:24:13+00:00Added an answer on June 3, 2026 at 4:24 pm

    TL;DR: Module is the superclass of Class. Module is an instance of Class.


    Let me try to explain it more clearly. Please forgive my handwritten drawings – I don’t have any fancy drawing software.

    Every class in Ruby has 1 superclass*.

    enter image description here

    *Except for BasicObject, which doesn’t have a superclass.

    Read the above graphic like this: The superclass of Float is Numeric. The superclass of Numeric is Object, etc…

    When you instantiate an object, the object will be an instance of some class. For example, “Nathan” is an instance of the String class. So is “Joe” or “John”. 1 is an instance of the Fixnum class, as are 2, 3, 4, etc…

    enter image description here

    Read the above graphic like this: “Joe” is an instance of String. 1 is an instance of Fixnum, etc…

    Well, in Ruby, unlike in most other languages, Class is a just another class, and it can be instantiated, too, just like Fixnum or String.

    enter image description here

    Read the above graphic like this: 0.01 is an instance of Float. String is an instance of Class, etc…

    Realize that Fixnum is an instance of Class, just like “Nathan” is an instance of String. Just like “John” is an instance of String, Float is just an instance of Class. Every class is just an an instance of Class, even Class itself!

    Whenever you write a new class in your app, you are just instantiating a new object whose class is Class, just like Hash.new instantiates a new Hash, or “Nathan” instantiates a new String.

    # By running this, you will be instantiating a new Class, and 
    # it will be named Post 
    class Post < ActiveRecord::Base
    end
    
    # Here is another perfectly valid way to write the above code:
    Post = Class.new(ActiveRecord::Base)
    
    # you can even instantiate a Class without giving it an explicit name:
    x = Class.new(ActiveRecord::Base)
    
    # and since your new things are classes, they can be instantiated
    obj1 = Post.new
    obj2 = x.new
    

    Furthermore, Module is just another instance of Class. Whenever you write a new module in your app, you are just instantiating a new Module.

    # this will instantiate a new Module, and assign it to Foo
    module Foo
    end
    
    # Here is another perfectly valid way to write the above code:
    Foo = Module.new
    
    # you can even instantiate a Module without giving it an explicit name.
    m = Module.new
    

    An aside: A Module is just a collection of methods and constants. Classes are also a collection of methods and constants, but with the added functionality of being able to be instantiated. A module cannot be instantiated. That is, m.new will not work.

    So, referring back to the top graphic, your question can be answered directly:

    So a class’s parent is module, but module is a class?

    You can see from the top graphic: Module is the superclass of Class.

    From the bottom graphic: Module is an instance of Class.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

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.