Created
January 16, 2012 23:10
-
-
Save eegrok/1623511 to your computer and use it in GitHub Desktop.
threequals is called at the class level
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
| module ModuleWithSelf | |
| def self.===(obj) | |
| obj === "blah" | |
| end | |
| end | |
| module ModuleNoSelf | |
| def ===(obj) | |
| obj === "blah" | |
| end | |
| end | |
| class ClassWithSelf | |
| def self.===(obj) | |
| obj === "blah" | |
| end | |
| end | |
| class ClassNoSelf | |
| def ===(obj) | |
| obj === "blah" | |
| end | |
| end | |
| # this returns true | |
| if ModuleWithSelf === "blah" | |
| puts "module with self worked" | |
| else | |
| puts "module with self FAILED" | |
| end | |
| # this returns false | |
| if ModuleNoSelf === "blah" | |
| puts "module no self worked" | |
| else | |
| puts "module no self FAILED" | |
| end | |
| # this returns true, rest return false | |
| if ClassWithSelf === "blah" | |
| puts "class with self worked" | |
| else | |
| puts "class with self FAILED" | |
| end | |
| if ClassNoSelf === "blah" | |
| puts "class no self worked" | |
| else | |
| puts "class no self FAILED" | |
| end | |
| if ModuleWithSelf === "blee" | |
| puts "module with self FAILED" | |
| else | |
| puts "module with self worked" | |
| end | |
| if ModuleNoSelf === "blee" | |
| puts "module no self FAILED" | |
| else | |
| puts "module no self worked" | |
| end | |
| if ClassWithSelf === "blee" | |
| puts "class with self FAILED" | |
| else | |
| puts "class with self worked" | |
| end | |
| if ClassNoSelf === "blee" | |
| puts "class no self FAILED" | |
| else | |
| puts "class no self worked" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment