Ruby String Methods (Ultimate Guide)

A string is a sequence of characters. Strings are objects so they have a lot of methods you can use to do things with them. In this article… You’ll discover the most useful Ruby string methods with examples! How to Get The String Length Easy: You can also use length, instead of size, they do … Read more

Everything You Need to Know About Nil

Nil… What is it, really? Well, nil is a special Ruby object used to represent an “empty” or “default” value. It’s also a “falsy” value, meaning that it behaves like false when used in a conditional statement. Now: There is ONLY one nil object, with an object_id of 4 (or 8 in 64-bit Ruby), this … Read more

Ruby Is Hiding Errors From You!

Ruby will intentionally hide some errors & exceptions from you. Sometimes this can be useful. Like when using the Kernel#loop method with a block, the loop will stop when a StopIteration exception is raised. But other times this can make your debugging sessions a lot harder. Let’s see some examples! Hidden Exception: Comparable Module + … Read more

Learn to Implement & Use Prefix Trees in Ruby

A prefix tree (also known as a trie) is a data structure that helps you organize a word list & quickly find words that start with a specific prefix. For example, you can find all the words in your dictionary that start with the letters “ca”, such as “cat” or “cape”. Look at this picture: … Read more