0
0
Rubyprogramming~5 mins

Debugging with pry and byebug in Ruby - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the pry gem in Ruby?
The pry gem allows you to pause your Ruby program and open an interactive console to inspect variables, test code, and understand program flow.
Click to reveal answer
beginner
How do you start a debugging session using byebug in Ruby?
Insert the line byebug in your Ruby code where you want to pause execution. When the program runs and reaches this line, it opens a debugging console.
Click to reveal answer
beginner
What command in pry lets you continue program execution after pausing?
Use the command continue or exit in the pry console to resume running the program after inspection.
Click to reveal answer
intermediate
Name one advantage of using byebug over simple puts debugging.
byebug lets you step through code line-by-line, inspect variables at any point, and control execution flow, which puts cannot do.
Click to reveal answer
beginner
How do you install pry and byebug gems for debugging?
Add gem 'pry' and gem 'byebug' to your Gemfile and run bundle install, or install directly with gem install pry byebug.
Click to reveal answer
Which command starts an interactive debugging session with byebug?
AInsert <code>byebug</code> in the code
BRun <code>ruby debug</code>
CUse <code>pry.start</code>
DCall <code>debugger()</code>
What does the pry gem provide?
AA tool to automatically fix bugs
BAn interactive console to inspect and test code
CA syntax checker
DA code formatter
Which command in pry resumes program execution after pausing?
Abreak
Bpause
Cstop
Dexit
What is a key benefit of using byebug instead of puts for debugging?
ARun code faster
BAutomatically fix errors
CStep through code line-by-line
DHide errors from users
How do you install pry and byebug gems?
AAdd to Gemfile and run bundle install
BUse <code>npm install</code>
CDownload from Ruby website
DNo installation needed
Explain how you would use pry to debug a Ruby program.
Think about where to put the pause and what happens next.
You got /5 concepts.
    Describe the steps to start a debugging session with byebug and how to control execution.
    Focus on how to pause and move through code.
    You got /5 concepts.