Last active
April 24, 2018 19:42
-
-
Save enebo/8a83436ec8c35942b61f9edeb69c7341 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 Bignum | |
def ==(o) | |
puts "==" | |
super | |
end | |
def eql?(o) | |
puts "eql?" | |
super | |
end | |
end | |
10_000_000_000_000_000.eql? 1 | |
1.eql? 10_000_000_000_000_000 | |
class MyNumber < Numeric | |
def ==(o) | |
puts "==" | |
super | |
end | |
def eql?(o) | |
puts "eql?" | |
super | |
end | |
end | |
m = MyNumber.new | |
10.eql? m | |
m.eql? 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment