Open
Description
@ccare For you
Approvable solution without comment.
class HighScores
attr_reader :scores
def initialize(scores)
@scores = scores
end
def personal_best
scores.max
end
def latest
scores.last
end
def personal_top_three
scores.max(3)
end
end
Approvable solution with comment (ruby.high-scores.attr_reader
).
class HighScores
def initialize(scores)
@scores = scores
end
def scores
@scores
end
def personal_best
scores.max
end
def latest
scores.last
end
def personal_top_three
scores.max(3)
end
end
Approvable solution with comment (ruby.high-scores.max_not_reverse
and param of {method: 'take'}
).
class HighScores
def initialize(scores)
@scores = scores
end
def scores
@scores
end
def personal_best
scores.max
end
def latest
scores.last
end
def personal_top_three
scores.reverse.take(3)
end
end
Approvable solution with comment (ruby.high-scores.max_not_reverse
and param of {method: 'first'}
).
class HighScores
def initialize(scores)
@scores = scores
end
def scores
@scores
end
def personal_best
scores.max
end
def latest
scores.last
end
def personal_top_three
scores.reverse.first(3)
end
end
@ccare You'll want to copy/paste the two-fer scaffolding to get started, then add one solution at a time. The key to developing this is to use pry
. Reach out to @kytrinyx on Slack if you'd like her to talk you through this as she explained it to me :)