What is A REPL in Ruby? (IRB, Pry & More)

REPL stands for Read-Eval-Print-Loop. It’s a program that allows you to type Ruby code & see the result directly. One popular REPL is irb. Another is pry. They’re useful because you can quickly test how some Ruby code works. For example: If you’re trying to convert an array of strings into an array of integers. … Read more

How to Run System Commands From Ruby

If you want to run an external command from Ruby… …like wkhtmltopdf to convert an HTML file into a PDF. There are a few Ruby methods you can use. Depending on the method you use you’ll get different results. Let’s explore these methods together! The Ruby System Method The Ruby system method is the simplest … Read more

How To Use Heredoc in Ruby

What is a heredoc? A heredoc is a way to define a multiline string, while maintaining the original indentation & formatting. This is used to embed snippets of code, like SQL or HTML. Here’s an example: query =

Dup vs Clone in Ruby: Understanding The Differences

Did you know that you can copy an object in Ruby? Not only that, but there are two different methods to do this! These methods are: dup clone We will explore the differences in a moment, but first… Why would you want to clone an object? Many objects in Ruby are mutable, you can change … Read more