IRB, which stands for Interactive Ruby, is the standard REPL which is bundled along with ruby. Pry is a popular alternative for IRB, which has many developer-friendly features like tab compilation and syntax highlighting. One of the most heavily used features of pry is the ability to introduce a REPL session in between your code execution for better debugging. Instead of using
puts to print the result and various variables, this helps us try out various codes and fixes in between the code to find the right solution.
[caption id="" align="aligncenter" width="625"] binding.pry being used.[/caption]
binding.irb in your code, you need to require the IRB library to your code and call
binding.irb where you want to introduce the REPL.
require 'irb' # all the codes before the binding binding.irb # all the codes after the bindingand you will see a REPL like below. ]]>