Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions student.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def initialize(first_name, last_name, grade)
def senior?
grade == 12
end

def junior?
grade == 11
end

def to_s
"#{last_name}, #{first_name}"
Expand All @@ -20,11 +24,22 @@ def seniors(students)
students.select { |student| student.senior? }
end

def juniors(students)
students.select {|student| student.junior? }
end


fred = Student.new("Fred", "James", 12)
sarah = Student.new("Sarah", "Smith", 12)
jack = Student.new("Jack", "Gong", 11)
all_students = [fred, sarah, jack]

seniors(all_students).each do |student|
puts "Seniors"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this output when you run it locally?

puts student
end

juniors(all_students).each do |student|
puts "Juniors"
puts student
end