Guest User

Untitled

a guest
Sep 11th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.26 KB | None | 0 0
  1. class ScoreKeeper
  2. def initialize
  3.            @total_score = @count = 0
  4. end
  5. def <<(score)
  6.         @total_score += score
  7.            @count += 1
  8.            self
  9. end
  10. def average
  11. fail "No scores" if @count.zero?
  12.            Float(@total_score) / @count
  13. end
  14. end
Advertisement
Add Comment
Please, Sign In to add comment