Skip to content

Instantly share code, notes, and snippets.

@jacegu
Created December 6, 2010 10:32
Show Gist options
  • Save jacegu/730107 to your computer and use it in GitHub Desktop.
Save jacegu/730107 to your computer and use it in GitHub Desktop.
A little example to show how *, +, -, / and so on are just methods
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