Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Base = Struct.new :foo, :bar do
- def hash
- members.inject(0) {|h,m| ((h << 2) ^ self[m].hash) & 0xFFFF}
- end
- def ==(o)
- members.all? {|m| self[m] == o[m]}
- end
- end
- class X < Base
- end
- class Y < Base
- end
- x = X.new 1,2
- y = Y.new 1,2
- p x == y
Add Comment
Please, Sign In to add comment