Created
May 13, 2014 12:49
-
-
Save pielgrzym/393fafcf3c66f77586d3 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 OV | |
def vals | |
['a', 'b', 'c'] | |
end | |
# this will make this work: | |
# OV.new == 'a' | |
# true | |
# OV.new == 'b' | |
# true | |
# but not this: | |
# 'b' == OV.new | |
# false | |
def ==(other) | |
vals.include?(other) | |
end | |
# when this method is defined def ==() works THE OTHER WAY AROUND | |
# so this will work: | |
# 'a' == OV.new | |
# true | |
# 'b' == OV.new | |
# true | |
def to_str | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment