Idioms and stylistic preferences for readability and malleability.
Category: Style
Episode #207: Conversion Function
In this episode we create a function for converting arbitrary values into Feet objects.
Episode #188: Fail And Raise
Today's episode is about a semantic convention for error handling that I learned from Jim Weirich.
Episode #166: Not Implemented
Ruby doesn't have a built-in concept of "abstract" classes, but sometimes we want a way to show other programmers when methods are left as an exercise for the implementor. This …
Episode #111: Symbol Placeholder
Nobody wants to debug an "undefined method for NilClass" error. Today's episode shows a little trick for making these errors more meaningful.
Episode #094: Bang Bang
Have you ever found yourself looking for a '#to_bool' method in Ruby? This episode explores why boolean conversion isn't needed as often as you might think; as well as how …
Episode #090: class<<self
Ruby gives as a number of options when it comes to defining class methods. This episode starts by demonstrating three of them, and then gets a bit opinionated.
Episode #082: Inline Assignment
It's a small thing, but judicious use of inline assignment can make code more DRY and concise. In this episode we look at how to do it, and when.
Episode #064: Yield or Enumerate
A number of Ruby standard library methods return an Enumerator if no block is passed to them. In this episode, we'll learn how to emulate this behavior in our own …
Episode #050: Include Namespace Module
Sometimes a utility module is overkill. In this episode, we make a namespace module do double-duty.