mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-21 09:40:13 +01:00
13 lines
No EOL
180 B
Ruby
13 lines
No EOL
180 B
Ruby
class Adder
|
|
def initialize
|
|
@addends = []
|
|
end
|
|
|
|
def <<(val)
|
|
@addends << val
|
|
end
|
|
|
|
def sum
|
|
@addends.inject(0) { |sum_so_far, val| sum_so_far + val }
|
|
end
|
|
end |