Course Content

Course Content


In Ruby, every object has a boolean value, which means it is either true or false in a boolean context. Those who are "truthy" in this context are "truthy," while those who are "falsey" are "falsey." Only true and nil are "falsey" in Ruby; everything else is "truthy."

Ruby is an outlier in that it lacks a Boolean data type, despite having explicit values to represent true and false. Instead, in Ruby, the one instance of TrueClass represents truth, and the sole instance of FalseClass represents lie.

Two strings or boolean values are equal if their length and value are the same. To check if two strings are equal in Ruby, we can use the double equality sign ==. A boolean result of True is returned if they are both the same length and content. Otherwise, False is returned as a Boolean value.

In order to convert a string to a Boolean, you will need to use the Boolean() function. This function takes in any type of data and converts it into its boolean equivalent. You can then use this boolean value for whatever you need it for.

There are three types of booleans:

  • ON/OFF
  • YES/NO

Share With Friend

Have a friend to whom you would want to share this course?

Download LearnVern App

App Preview Image
App QR Code Image
Code Scan or Download the app
Google Play Store
Apple App Store
598K+ Downloads
App Download Section Circle 1
4.57 Avg. Ratings
App Download Section Circle 2
15K+ Reviews
App Download Section Circle 3
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere