Episode #082: Inline Assignment

Have you ever programmed in C/C++? Back when I used those languages for my day job, it often seemed like half of any given function was taken up with variable declarations. Ruby, with its block-oriented syntax, does away with most of this declaration boilerplate. But there are still a few cases where you can find yourself needing to assign a variable on a separate line, only to use it on just one other line of code.

In this episode, you'll learn a syntactic trick that lets you create a new object and give a name to it at the same time, without interrupting the visual flow of your code. Enjoy!

This page is just for members. Sign in or subscribe to gain access!