Guest User

Untitled

a guest
Jun 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. Base = Struct.new :foo, :bar do
  2. def hash
  3. members.inject(0) {|h,m| ((h << 2) ^ self[m].hash) & 0xFFFF}
  4. end
  5.  
  6. def ==(o)
  7. members.all? {|m| self[m] == o[m]}
  8. end
  9. end
  10.  
  11. class X < Base
  12. end
  13. class Y < Base
  14. end
  15. x = X.new 1,2
  16. y = Y.new 1,2
  17. p x == y
Add Comment
Please, Sign In to add comment