Skip to content

Instantly share code, notes, and snippets.

@pielgrzym
Created May 13, 2014 12:49
Show Gist options
  • Save pielgrzym/393fafcf3c66f77586d3 to your computer and use it in GitHub Desktop.
Save pielgrzym/393fafcf3c66f77586d3 to your computer and use it in GitHub Desktop.
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