Ruby 2.4 will have the feature to introduce a REPL session, using IRB, in between your code execution for better debugging. 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.
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.
# all the codes before the binding
# all the codes after the binding
and you will see a REPL like below.