0
0
Rubyprogramming~20 mins

Debugging with pry and byebug in Ruby - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Ruby Debugging Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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"
A10
Bnil
CError: undefined local variable or method `x`
DNothing is printed
Attempts:
2 left
💡 Hint
Remember that binding.pry pauses execution and lets you inspect variables in the current scope.
Predict Output
intermediate
2: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
A10
B12
CError: undefined local variable or method `y`
DNothing, program continues without pause
Attempts:
2 left
💡 Hint
Byebug pauses execution and lets you evaluate expressions in the current context.
Predict Output
advanced
2: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
ANo error, program runs fine
BRuntimeError: Pry session already started
CNoMethodError: undefined method `start` for Pry:Module
DSyntaxError: unexpected end-of-input
Attempts:
2 left
💡 Hint
Check if Pry.start is a valid method call.
Predict Output
advanced
2: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
A7
BNothing, program stuck at breakpoint
CError: undefined local variable or method `x`
D3
Attempts:
2 left
💡 Hint
After continuing, the program runs the next lines normally.
🧠 Conceptual
expert
3:00remaining
Which option correctly explains the difference between pry and byebug?
Choose the best explanation of how pry and byebug differ in Ruby debugging.
APry only works with Rails apps; byebug only works with Ruby scripts.
BPry and byebug are identical tools with different names.
CPry is used for performance profiling; byebug is used for syntax checking.
DPry is an interactive REPL allowing live code inspection and modification; byebug is a step-by-step debugger focused on breakpoints and stepping through code.
Attempts:
2 left
💡 Hint
Think about how each tool lets you interact with running code.