Menu
Coddy logo textTech

Project Overview

Part of the Logic & Flow section of Coddy's Ruby journey — lesson 48 of 56.

You're going to build a small student records system as a set of methods that all share one nested hash. Different shape from the Library Manager, no menu loop this time, just functions you'll keep extending.

The state lives in a single top-level hash:

student_records = {}

Each entry will be keyed by name, with a hash value carrying the student's age, grades, and courses:

{
  "Alice" => { age: 20, grades: [], courses: ["Math", "Physics"] }
}

Each lesson adds one method that operates on this hash: add_student, add_grade, average_grade, list_by_course, top_students.

challenge icon

Challenge

Beginner

Initialize an empty hash named student_records at the top of your file. Then print it with inspect so the test sees:

{}

That's the whole task, this lesson just sets up the shared state for everything that follows.

Cheat sheet

Student records system uses a single nested hash as shared state:

student_records = {}

Each entry is keyed by student name with a hash containing age, grades, and courses:

{
  "Alice" => { age: 20, grades: [], courses: ["Math", "Physics"] }
}

Use inspect to print a hash's contents:

puts student_records.inspect

Try it yourself

# TODO: initialize student_records = {} and print it with inspect
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Logic & Flow