Chapter 9. Collection and container objects
- Sequentially ordered collections with arrays
- Keyed collections with hashes
- Inclusion and membership tests with ranges
- Unique, unordered collections with sets
- Named arguments using hash syntax
In programming, you generally deal not only with individual objects but with collections of objects. You search through collections to find an object that matches certain criteria (like a magazine object containing a particular article); you sort collections for further processing or visual presentation; you filter collections to include or exclude particular items; and so forth. All of these operations, and similar ones, depend on objects being accessible in collections. ...
Get The Well-Grounded Rubyist, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.