Add juniors, sophomores, and freshmen#18
Open
harrisongill wants to merge 3 commits intoRubyoffRails:masterfrom
harrisongill:master
Open
Add juniors, sophomores, and freshmen#18harrisongill wants to merge 3 commits intoRubyoffRails:masterfrom harrisongill:master
harrisongill wants to merge 3 commits intoRubyoffRails:masterfrom
harrisongill:master
Conversation
Member
|
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). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.