Skip to Content
Effective Ruby: 48 Specific Ways to Write Better Ruby
book

Effective Ruby: 48 Specific Ways to Write Better Ruby

by Peter Jones
September 2014
Intermediate to advanced content levelIntermediate to advanced
240 pages
7h 2m
English
Addison-Wesley Professional
Content preview from Effective Ruby: 48 Specific Ways to Write Better Ruby

3. Collections

It’s tempting to think of Ruby’s collection classes as containers. If you squint and focus on the two rock stars of the core library, Array and Hash, this is certainly true. But what about the often-used Range class? Is it a container? Does having an each method and including the Enumerable module make a class a container?

Alright...I might have stretched that a bit far. You already know that Ruby has several classes that are clearly not containers but use Enumerable. That’s why we throw around the term “collection,” which is sometimes synonymous with “container,” but obviously not always. The first classes you probably played around with while learning Ruby are either Array or Hash. That’s because they’re really simple to use ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Ruby Way: Solutions and Techniques in Ruby Programming, Third Edition

The Ruby Way: Solutions and Techniques in Ruby Programming, Third Edition

Hal Fulton, André Arko
Ruby Cookbook, 2nd Edition

Ruby Cookbook, 2nd Edition

Lucas Carlson, Leonard Richardson

Publisher Resources

ISBN: 9780133847086Purchase book