Created
December 6, 2010 10:32
-
-
Save jacegu/730107 to your computer and use it in GitHub Desktop.
A little example to show how *, +, -, / and so on are just methods
This file contains hidden or 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 Fixnum | |
def +(other) | |
self - other | |
end | |
def *(other) | |
self / other | |
end | |
def ==(other) | |
true | |
end | |
end | |
puts " 2 + 2 = #{2 + 2}" | |
puts " 10 * 5 = #{10 * 5}" | |
puts " 7 == 2 #{7 == 2}" | |
puts " 5 == 5 #{5 == 5}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment