ruby - grade-school

This commit is contained in:
James Walker 2018-10-24 11:05:34 -04:00
parent da10e318e4
commit ddf33000c8
Signed by: walkah
GPG Key ID: 3C127179D6086E93

View File

@ -1,3 +1,4 @@
# School class
class School class School
def initialize def initialize
@roster = {} @roster = {}
@ -8,9 +9,7 @@ class School
end end
def add(name, grade) def add(name, grade)
if @roster[grade].nil? @roster[grade] ||= []
@roster[grade] = []
end
@roster[grade].push(name).sort! @roster[grade].push(name).sort!
end end