Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def CustomMergingCollection
- include Enumerable
- def initialize(hash={})
- @hash = hash
- end
- def each(&block)
- @hash.values.each(&block)
- end
- def []=(other)
- idx = other.idx
- return @hash[idx] = other unless @hash[idx]
- @hash[idx] = combine(current, other)
- end
- private
- def combine(first, second)
- # ...
- end
- end
Add Comment
Please, Sign In to add comment