Skip to content

Instantly share code, notes, and snippets.

@krainboltgreene
Created October 27, 2014 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krainboltgreene/fdeeef924cad2ce13977 to your computer and use it in GitHub Desktop.
Save krainboltgreene/fdeeef924cad2ce13977 to your computer and use it in GitHub Desktop.
class Calculator
def doubler(number)
number * 2
end
def runner(number)
yield(number)
end
def input(number, operation)
runner(number, &method(operation))
end
end
# pry(main)> calculator = Calculator.new
# => #<Calculator:0x007fc3432884e0>
# pry(main)> calculator.input(6, :doubler)
# => 12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment