December 2014
Intermediate to advanced
164 pages
2h 14m
English
CHAPTER 7
![]()
Booleans
Booleans within Ruby are actually known as parts of the TrueClass and FalseClass, rather than a Boolean Data Type as such. It is worth noting that nil (Ruby's version of a null) is not a Boolean.
2.1.1 :001 > true.class => TrueClass2.1.1 :002 > false.class => FalseClass
Creating Boolean Values
Creating a Boolean value within Ruby is similar to creating a String/Numeric value. You simply set a variable to the value required (true or false):
2.1.1 :001 > test = true => true2.1.1 :002 > puts testtrue => nil2.1.1 :003 > test.class => TrueClass
Expression Tests
Within Ruby a number of expression tests return a Boolean value; which ...
Read now
Unlock full access