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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:13:27+00:00 2026-06-02T06:13:27+00:00

I am new to Ruby and came across the defined? operator. I thought the

  • 0

I am new to Ruby and came across the defined? operator. I thought the ? implied that the method returned true/false but defined? returns a description of the identifier if it is defined.

I know that there is a true/false component in that the identifier is or is not defined but I thought that the ? meant that the return value always had to be true/false`. Help?

  • 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-02T06:13:28+00:00Added an answer on June 2, 2026 at 6:13 am

    It returns a “truthy” value that is either “truthy-true” or “truthy-false”.

    In Ruby, there are only two things that are truthy-false:

    • false (the singleton object)
    • nil (the singleton object)

    Anything else is considered truthy-true. Tons of Ruby code leverages this fact for predicates. Checks for predicates, as such, should be:

    if list.empty?
    

    not:

    if list.empty? == true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fairly new to Ruby but I came across this weird gist where a
I'm new to Ruby and came across something that confused me a bit. I
I'm new to Ruby and thought that it would be a great way to
Hi I'm pretty new with Ruby On Rails, and came across this problem. I
I'm relatively new to ruby and i came from php. One thing that it
new to ruby, and rails... but not to the amp stack. my preferred method
I'm farily new to the ruby language and I came across this line of
I am quite new to ruby, I came across the following code in rails,
I'm learning Ruby and RoR at the moment, and I came across this: <%
I'm using the C extension methods to create a new ruby array, but RARRAY_LEN

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.