Skip to content

Instantly share code, notes, and snippets.

@wycats
Created March 28, 2010 19:38
Show Gist options
  • Save wycats/346980 to your computer and use it in GitHub Desktop.
Save wycats/346980 to your computer and use it in GitHub Desktop.
class Foo < String
attr_reader :omg
def initialize(str, omg)
super str
@omg = omg
end
def hash
[@omg, to_str].hash
end
def eql?(other)
[@omg, to_str] == [other.omg, other.to_str]
end
def inspect
"#<@omg: #{@omg} #{self.to_str}>"
end
end
foo = Foo.new("holla", 1)
bar = Foo.new("holla", 2)
x = {}
x[foo] = 1
x[bar] = 2
p x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment