Challenge 1: Checking Truthiness
Explore how Ruby handles truthiness and equivalence by testing various objects in a practical coding challenge. Learn to interpret boolean evaluation results with the double negation operator to deepen your understanding of Ruby's conditional behavior.
We'll cover the following...
We'll cover the following...
Problem statement
This exercise is about validating what we’ve learned about truthiness, and printing the results in a tabular form.
Consider the following array:
objects = [true, false, nil, 0, 1, "", []]
Add some code so that it outputs the following table:
object | !!object
true | [true|false]
false | [true|false]
nil | [true|false]
0 | [true|false]
1 | [true|false]
"" | [true|false]
[] | [true|false]
Note: The last column should be filled in with either
trueorfalse, depending on what the!!objectoperation, which is the same asnot not object, returns for each of the objects.