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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:36:55+00:00 2026-06-16T00:36:55+00:00

Considering that everything in Ruby is an object and we can open irb and

  • 0

Considering that everything in Ruby is an object and we can open irb and type things like 4.class and "Text".class to see from which class an object is, why do if.class and unless.class give no return value?

  • 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-16T00:36:56+00:00Added an answer on June 16, 2026 at 12:36 am

    Considering that everything in Ruby is an object

    That depends on your definition of “object” and every-“thing“. “Object” can mean “entity that can be manipulated by the program” (which I will call object from now on), or “value that is a member of the object system” (which I will call Object from now on).

    In Ruby, everything that can be manipulated by the program (i.e. every object) is also an Object, i.e. an instance of a class. This is unlike Java, for example, where primitives can be manipulated by the program (i.e. are objects in that sense of the word), but aren’t Objects. In Ruby, this distinction doesn’t exist: every object is an Object and every Object is also an object.

    However, there are things in the language, which cannot be manipulated by the program and which aren’t instances of a class, i.e. they are neither object s nor Objects. These are, for example, methods, variables, syntax, parameter lists, argument lists, keywords.

    Note: you can use Ruby’s reflection API to give you an object that represents a method or a parameter list, but that object is only a proxy, it is not the real thing.

    So, when we say “everything is an object“, what we really mean is that “every object is an Object“, i.e. that everything which can be manipulated by the program is also a member of the object system, or in other words, there are no values outside of the object system (unlike primitives in Java). We do not mean that everything that exists in the language can also be manipulated at runtime by the program.

    why do if.class and unless.class give no return value

    Well, first off, even if if were an object, those don’t do what you think they do: when you say something like foo in Ruby, it means either “dereference the local variable foo” or “call the method foo with self as the implicit receiver and no argument list”. So,

    if.class
    

    would either give you the class of the object referenced by the local variable if or the class of the object returned by the method if, but never the class of if itself.

    But the if control flow keyword isn’t an object, anyway (neither an object nor an Object) because keywords and control flow aren’t objects in Ruby.

    In the book The Ruby Programming Language by Matz and David Flanagan it says on page 2:

    every value is an object

    Note, it doesn’t say every-thing, only every value.

    See also the question Is variable is object in ruby?

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

Sidebar

Related Questions

Considering that simple java code which would not work: public class Bar extends AbstractBar{
I would like to know , considering that Clojure uses 32-bit hash for its
Considering that my application is still in development, from time to time error appears
Currently writing a class where methods that I am considering making private are spread
I know that a SQL Server full text index can not index more than
Considering that I have a Schema named SBST I want to find all empty
Considering that the two machine's time settings are not synced, is it still possible
considering that metric is delay in distance vector routing algorithm, is it possible that
I'm trying to create programmability a home shortcut for any installed application. Considering that
I'm considering a project that involves the browser user being able to screen capture

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.