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 =
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 =
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
Ruby’s performance has been improving a lot, version after version… and the Ruby development team is making every effort to make Ruby even faster! One of these efforts is the 3×3 project. The goal? Ruby 3.0 will be 3 times faster than Ruby 2.0. Part of this project is the new MJIT compiler, which is … Read more
You can give an alternative name to a Ruby method in two ways: Because they do the same thing in slightly different ways this can be a confusing topic. This image is a summary of the differences: Let’s explore these differences in more detail to get a solid understanding! The alias Keyword First we have … Read more
A new version of Ruby is coming with new features & performance improvements. Would you like to keep up with the changes? Let’s have a look! Endless Ranges Ruby 2.5 & older versions already support one form of endless range (with Float::INFINITY), but Ruby 2.6 takes this to the next level. The new endless range … Read more