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
BeginnerInitialize 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.inspectTry it yourself
# TODO: initialize student_records = {} and print it with inspect
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Logic & Flow
1Strings In Depth
String Methods OverviewString InterpolationIterating Over StringsSplit and JoinRecap - String Weaver4Blocks, Procs & Lambdas
What is a Block?do..end vs BracesThe yield KeywordBlock ParametersProcs and LambdasRecap - Custom Iterator7Hashes Part 2
Hash.new with DefaultsIterating HashesNested HashesMerging and TransformingRecap - Frequency Counter10Project - Student Records
Project OverviewAdd Student5Enumerable Powerhouse
Select and RejectChaining MapReduce / Injectcount, all?, any?, none?group_by and partitionsort_by, min_by, max_byRecap - Data Pipeline8Advanced Decision Making
Case with Classes & RegexMulti-value whenTernary OperatorInline if / unlessRecap - Grade Classifier