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.
Category: Premium Episodes
Episode #081: Implicit Splat
Delving further into Ruby's destructuring assignment, or "splat", mechanism, today we look at some cases where Ruby performs splatting without an explicit '*' operator.
Episode #080: Splat Basics
Ruby supports a limited form of destructuring assignment, in the form of the "splat" operator. In today's episode we go over splat basics, in order to lay a foundation for …
Episode #079: Concat
There is more than one way to concatenate arrays, but not all ways are created equal. In this episode we'll compare three approaches in terms of both semantics and efficiency.
Episode #078: Tail Part 7: Cooperating Objects
In a final refactoring to our pseudo-tail(1), we use an enumerator to encapsulate the process of searching text chunks for newlines.
Episode #077: Tail Part 6: Process As Object
Continuing to refactor our minimal tail(1) implementation, today we clean up a loop by encapsulating its state in a new object.
Episode #076: Tail Part 5: Idiom
So far, our reimplementation of tail(1) bears a striking resemblance to the style of code we might find in the C implementation of the same utility. In this episode we'll …
Episode #074: Tail Part 3: #rindex
We've figured out how to read chunks of text backwards from a file, now it's time to tackle searching that text for the beginnings of lines.
Episode #075: Tail Part 4: copy
Marching right along in our reimplementation of UNIX tail(1), today we tackle the problem of dumping the tail of the file to STDOUT once we've found the starting point.