Bird
0
0

Which of the following Ruby values will evaluate as false in a conditional statement?

easy📝 Conceptual Q1 of 15
Ruby - Operators and Expressions
Which of the following Ruby values will evaluate as false in a conditional statement?
A[] (empty array)
B0
C"" (empty string)
Dnil
Step-by-Step Solution
Solution:
  1. Step 1: Understand Ruby falsy values

    In Ruby, only false and nil are falsy.
  2. Step 2: Evaluate each option

    0, empty string, and empty array are all truthy values.
  3. Final Answer:

    nil -> Option D
  4. Quick Check:

    Check if value is exactly false or nil [OK]
Quick Trick: Only false and nil are falsy in Ruby [OK]
Common Mistakes:
MISTAKES
  • Assuming 0 is falsy
  • Assuming empty string is falsy
  • Assuming empty array is falsy

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes