Case with ranges and patterns
📖 Scenario: You are creating a simple program to categorize ages into life stages using Ruby's case statement with ranges and pattern matching.
🎯 Goal: Build a Ruby program that uses a case statement with ranges and patterns to print the life stage for a given age.
📋 What You'll Learn
Create a variable
age with a specific integer value.Create a variable
adult_age to set the minimum adult age.Use a
case statement with ranges and pattern matching to determine the life stage.Print the life stage as output.
💡 Why This Matters
🌍 Real World
Categorizing ages into groups is common in apps like surveys, games, or health trackers.
💼 Career
Understanding <code>case</code> with ranges and patterns helps in writing clear, readable decision-making code in Ruby.
Progress0 / 4 steps