Challenge - 5 Problems
Ruby Debugging Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output when using pry to inspect a variable?
Consider the following Ruby code snippet using pry. What will be printed when the program hits the
binding.pry line and you type x in the pry console?Ruby
require 'pry' x = 10 binding.pry puts "Done"
Attempts:
2 left
💡 Hint
Remember that
binding.pry pauses execution and lets you inspect variables in the current scope.✗ Incorrect
When the program pauses at binding.pry, you can type x to see its value, which is 10.
❓ Predict Output
intermediate2:00remaining
What happens when byebug hits a breakpoint?
Given this Ruby code using byebug, what will be the output when the program pauses at
byebug and you type y + 5 in the debugger console?Ruby
require 'byebug' y = 7 byebug puts y + 3
Attempts:
2 left
💡 Hint
Byebug pauses execution and lets you evaluate expressions in the current context.
✗ Incorrect
At the byebug line, the program pauses. Typing y + 5 evaluates to 12 because y is 7.
❓ Predict Output
advanced2:00remaining
What error does this code raise when using pry incorrectly?
What error will this Ruby code raise when run?
Ruby
require 'pry' Pry.start x = 5
Attempts:
2 left
💡 Hint
Check if
Pry.start is a valid method call.✗ Incorrect
Pry.start is not a defined method. The correct way to start a pry session is binding.pry.
❓ Predict Output
advanced2:00remaining
What is the output after continuing from a byebug breakpoint?
Given this Ruby code, what will be printed after you type
continue in the byebug console?Ruby
require 'byebug' x = 3 byebug x += 4 puts x
Attempts:
2 left
💡 Hint
After continuing, the program runs the next lines normally.
✗ Incorrect
After continue, x becomes 7 and is printed.
🧠 Conceptual
expert3:00remaining
Which option correctly explains the difference between pry and byebug?
Choose the best explanation of how pry and byebug differ in Ruby debugging.
Attempts:
2 left
💡 Hint
Think about how each tool lets you interact with running code.
✗ Incorrect
Pry provides a powerful interactive shell to inspect and modify code live. Byebug is designed for setting breakpoints and stepping through code execution.