thorpedosg

Untitled

Jul 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def CustomMergingCollection
  2. include Enumerable
  3.  
  4. def initialize(hash={})
  5. @hash = hash
  6. end
  7.  
  8. def each(&block)
  9. @hash.values.each(&block)
  10. end
  11.  
  12. def []=(other)
  13. idx = other.idx
  14. return @hash[idx] = other unless @hash[idx]
  15. @hash[idx] = combine(current, other)
  16. end
  17.  
  18. private
  19.  
  20. def combine(first, second)
  21. # ...
  22. end
  23. end
Add Comment
Please, Sign In to add comment