I have an array to which I continue to add blocks of code at different points in time. When a specific event occurs, the iterator iterates through this array and gives the blocks one by one.
Many of these blocks are the same, and I want to avoid repeating blocks.
This is a sample code:
@after_event_hooks = []
def add_after_event_hook(&block)
@after_event_hooks << block
end
Something like @after_event_hooks.uniqor @after_event_hooks |= blocknot working.
Is there a way to compare blocks or check their uniqueness?
source
share