Bird
0
0

What will be the output when running this Ruby code with byebug inserted?

medium📝 Predict Output Q13 of 15
Ruby - Ecosystem and Best Practices
What will be the output when running this Ruby code with byebug inserted?
def add(a, b)
  byebug
  a + b
end

puts add(2, 3)
A5
Bbyebug error
Cnil
DSyntaxError
Step-by-Step Solution
Solution:
  1. Step 1: Understand what byebug does

    It pauses execution allowing inspection but does not change the return value.
  2. Step 2: Trace the function call and output

    The method add(2, 3) returns 5, which is printed by puts.
  3. Final Answer:

    5 -> Option A
  4. Quick Check:

    byebug pauses but output is 5 [OK]
Quick Trick: byebug pauses but returns normal output [OK]
Common Mistakes:
  • Expecting byebug to change output
  • Thinking byebug causes errors
  • Confusing pause with program stop

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes