Group_by for categorization
📖 Scenario: You work at a bookstore that wants to organize books by their genre to make it easier for customers to find what they like.
🎯 Goal: You will create a Ruby program that groups a list of books by their genre using the group_by method.
📋 What You'll Learn
Create an array of hashes called
books with each book having :title and :genre keysCreate a variable called
grouped_books to store the result of grouping books by genre using group_byPrint the
grouped_books variable to show books categorized by genre💡 Why This Matters
🌍 Real World
Grouping items by category is common in apps like bookstores, music libraries, or inventory systems to help users find things easily.
💼 Career
Understanding how to group data efficiently is important for software developers working with collections, databases, or data analysis.
Progress0 / 4 steps