ruby - grade-school
This commit is contained in:
parent
da10e318e4
commit
ddf33000c8
@ -1,3 +1,4 @@
|
||||
# School class
|
||||
class School
|
||||
def initialize
|
||||
@roster = {}
|
||||
@ -8,9 +9,7 @@ class School
|
||||
end
|
||||
|
||||
def add(name, grade)
|
||||
if @roster[grade].nil?
|
||||
@roster[grade] = []
|
||||
end
|
||||
@roster[grade] ||= []
|
||||
@roster[grade].push(name).sort!
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user