Last active
November 4, 2015 06:57
-
-
Save kangkyu/77b38b98b67a5d631367 to your computer and use it in GitHub Desktop.
Today's Kata 11-03-2015
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
# For today, here's the problem for today | |
# Do whatever you need to do to Ruby, such that I can say: 9 - 8, and the answer will be 17 | |
# And if I say 9 + 8, the answer will be 1 | |
# so - i load whatever code you want to give me via a console, and I should be able to do the above | |
# turn plus into minus, minus into plus | |
# a short sentence explaining what you did and why it works would be nice | |
class Fixnum | |
alias_method :temp, :+ | |
alias_method :+, :- | |
alias_method :-, :temp | |
end | |
gem 'minitest', '>= 5.0.0' | |
require 'minitest/autorun' | |
class TestMinusPlus < Minitest::Test | |
def test_minus | |
assert_equal 17, 9 - 8 | |
end | |
def test_plus | |
assert_equal 1, 9 + 8 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment