Skip to content

Conversation

@harrisongill
Copy link

I tried to go a step further with all HS grades and also printing out the grade at the top of the grade list when run.

@jwo
Copy link
Member

jwo commented Dec 6, 2013

This looks great!

Seeing freshman/sophomore/juniors/seniors next to each other has me thinking that we are repeating ourselves. You absolutely did this episode quickly --- since you went beyond, I wonder if you'd like to try re-arranging to this:

grades = {freshman: 9, sophomore: 10, junior: 11, senior: 12) # hashes (see episode 6)

def all_students_for_grade(grade, students)
  grade_value = grades[grade]
  students.select {|s| s.grade == grade_value}.each do |s|
    puts "* #{s}"
  end
end

puts "Freshman"
all_students_for_grade(:freshman, students)

puts "\nSophomore"
all_students_for_grade(:sophomore, students)

puts "\nJunior"
all_students_for_grade(:junior, students)

puts "\nSenior"
all_students_for_grade(:senior, students)

Thoughts? Better or Worse? Anything else you think we could do? (even if you don't know exactly how in Ruby).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants