Created
October 27, 2014 20:58
-
-
Save krainboltgreene/fdeeef924cad2ce13977 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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