Bird
0
0

What will be the output of this Ruby code?

medium📝 Predict Output Q4 of 15
Ruby - Operators and Expressions
What will be the output of this Ruby code?
a = 7
b = 7
puts a == b
Afalse
Btrue
C7
Dnil
Step-by-Step Solution
Solution:
  1. Step 1: Understand the == operator

    The '==' operator compares if two values are equal and returns true or false.
  2. Step 2: Compare values of a and b

    Both a and b are 7, so a == b evaluates to true.
  3. Final Answer:

    true -> Option B
  4. Quick Check:

    Equality check returns true when values match [OK]
Quick Trick: == returns true if values are exactly equal [OK]
Common Mistakes:
MISTAKES
  • Expecting output to be the value itself
  • Confusing == with assignment =

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes