How Ruby Interprets and Runs Your Programs
In this post we'll follow the journey of a simple program as it's lexed, parsed and compiled into bytecode. We'll use the tools that Ruby gives us to spy on the interpreter every step of the way.
Brought to you by Honeybadger—simple application monitoring that helps developers move fast and fix things.
In this post we'll follow the journey of a simple program as it's lexed, parsed and compiled into bytecode. We'll use the tools that Ruby gives us to spy on the interpreter every step of the way.
Many problems faced by beginning Rubyists are caused by not understanding self. Join me and take a deep dive into self in Ruby under common and uncommon conditions.
In this post, we'll dive into regex conditionals and discuss how to work around the limitations in Ruby's implementation of them
Are refinements slow? I wrote a few benchmarks to find out. The answer was surprising.
If you've never used Ruby's refinements, you might be surprised to learn that they're lexically scoped. We'll discuss what this means, and the implications for your code.
When you treat your collections as enumerators, you get to use all your favorite functions like #map and #reduce without having to write any extra code. In this post I show you how easy it is to create enumerators on the fly, without defining extra classes or messing around with the Enumerable module.
These days it's pretty common to see #freeze used in Ruby code. But it's often not entirely clear WHY freeze is being used. In this post we'll look at the most common reasons a developer might freeze variables.
If you want your app to behave well in a unix environment, it's important that it exit correctly. In this post you'll learn all about unix exit codes, the mechanism that Ruby uses to exit a program, and how you can add custom behavior on exit.
But buried within Ruby's nesting implementation - and Rails' autoload system - are a few traps that can cause your code to fail in strange and wonderful ways. In this post, we'll discuss the origin of these traps and how you can avoid them.
It's often useful to be able to get the most recent exception, even if your code doesn't control the lifecycle of that exception. In this post we explore a few of the ways to do this.
Did you know that Ruby provides a way for your script to use its own source file as a source of data? It's a neat trick that can save you some time when writing one-off scripts and proofs of concept. Let's check it out!
Have you ever had a bunch of data in an array, but needed to do a key/value lookup like you would with a hash? Fortunately, Ruby provides a mechanism for treating arrays as key-value structures. Let's check it out!
Files are just large collections of lines or characters. Lazy enumerators make it possible to to some very interesting and powerful things with them.
Just how much slower are exceptions than other flow control mechanisms? In this post we use a simple benchmark to find out.
It's a common misconception that the raise method only accepts exceptions as its argument. This post will show you how you can raise ANYTHING, including numbers, dates, and your own custom classes.
One of the nice things about working with rails is that when something goes wrong in development, you get a really nice error detail page. Today we're going to take a look at how these fancy error pages work.
It’s easy to find code snippets that will delete the jobs from one Sidekiq queue. But we have lots of queues. I want to clear the jobs from all of them. After a little digging, I came up with an answer that seems to work well.
Fiddle is a little-known module that was added to Ruby's standard library in 1.9.x. It allow you to interact directly with C libraries from Ruby. In this post we'll start with some simple examples and finish by using termios to talk to an arduino over a serial port.
Sometimes the standard backtrace / error message combo isn't enough. Sometimes you need extra data to locate the cause of an error. In this post we'll discuss three easy ways to add more context to your exceptions.
If you've ever taken a look at Ruby's exception hierarchy, you may have noticed something weird. In addition to all of the normal exceptions like RuntimeError and NoMethodError, there's an odd reference to Errno::* . This post discusses what these exceptions are and how to interpret them.