In previous episodes we've touched on Enumerator in passing. This time it'll take center stage, as we explore just what an Enumerator is and what it's good for.
Tag: containers
Episode #045: Hash Default Value
This cautionary episode demonstrates and explains a Hash gotcha that often comes as a surprise.
Episode #044: #one?
Somtetimes you need to know if exactly one element in a collection has a given property. For that situation, we have the #one? predicate method.
Episode #038: Caller-Specified Fallback
Sometimes it's hard to decide how to handle a failure in a method call. Raise an exception? Return a nil? Log an error? The best choice may differ depending on …
Episode #034: Struct from Hash
For such similar and broadly useful data structures, Struct and Hash are surprisingly incompatible. In this episode we look at some ways to smooth over their differences, and answer a …
Episode #032: Hash Default Blocks
Following on to the episodes about #fetch, today's episode answers the question: what do we do when we want the same defaulting behavior everwhere a Hash is used?
Episode #025: OpenStruct
This episode focuses on OpenStruct, which makes it easy to create ad-hoc value objects from hashes.
Episode #020: Struct
In previous episodes we've used the Struct class in passing to quickly construct classes. This time, we put Struct in the spotlight, and put it through its paces. You'll want …
Episode #018: Subclassing Array
Sooner or later you'll want to subclass Array. This episode looks at why that's a bad idea, and presents an alternative.