Skip to content

Instantly share code, notes, and snippets.

@laser
Last active January 4, 2016 09:19
Show Gist options
  • Save laser/8601457 to your computer and use it in GitHub Desktop.
Save laser/8601457 to your computer and use it in GitHub Desktop.
number cruncher
class NumberCruncher
def initialize(calculator)
@calculator = calculator
end
def crunch(array_of_numbers)
@reduction ||= array_of_numbers.each do |number|
@calculator.add number
end
@calculator.result
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment