Ruby lists and maps
Work with ordered lists and key-value lookups. Follow a pickup roster, change a booking, or combine stock counts from two deliveries.
Lists · build and edit
- Array element assignmentCorrect the second stop on a shuttle route
- Array#delete_atTake a cancelled item off a packing list
- Array#dup and freezeFreeze the guest list used to print badges
- Array#insertInsert two pickup stops before the depot
- Array#mapClean the names on two visitor badges
- Array#pushAdd the last student to the bus register
- Array#rejectClear empty stock bins from the pick list
Lists · positions and ranges
- Array#fetchRead the second name on the pickup roster
- Array#index and Array#rindexFind both visits to the market
- Array#reverseRead a receipt history newest first
- Array#sliceSelect two orders for the packing bench
Maps · look up and assign
- Hash assignment and lookupUpdate the count for a shelf label
- Hash#key?Find a parcel whose driver is still unassigned
- Hash#key? before assignmentKeep the first reservation for a seat
Maps · combine and transform
- Hash default blockGroup two parcels on one delivery route
- Hash#dupKeep the price shown on yesterday's menu
- Hash#merge!Apply weekend opening hours
- Hash#sort and pair iterationPrint shelf totals in aisle order
- Hash#transform_valuesAdd a packing charge to each listed price
Other collection guides
- Enumerable#group_byGroup orders while preserving each order record
- Array#bsearch_indexFind the first threshold that covers a price
- Enumerable#each_consCompare every adjacent pair of readings
- Array#countCount items at the offer price
- Array#include?Check for a price in a sale list
- Array#minFind the cheapest item in a basket
- Enumerable#chunkCount runs of delivery statuses
- Enumerable#sumAdd the prices on a shopping list
- Hash#fetchShow a default when a product has no stock entry