Created
December 5, 2019 23:50
-
-
Save jenny-codes/191ad6ab5a79199a3d57b0dadbd7170b to your computer and use it in GitHub Desktop.
an interface that allows basic calculations with strings
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
%i(one two three four five six seven eight nine ten).each_with_index do |num_literal, i| | |
define_method(num_literal) do |block = nil| | |
block ? block.call(i + 1) : i + 1 | |
end | |
end | |
def plus(second) | |
lambda { |first| first + second } | |
end | |
def minus(second) | |
lambda { |first| first - second } | |
end | |
def times(second) | |
lambda { |first| first * second } | |
end | |
def devide(second) | |
lambda { |first| first / second } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment